home *** CD-ROM | disk | FTP | other *** search
- /*
- File: DrawPart.cpp
-
- Contains: Draw test part
-
- Owned by: SomVersion by Eric House; original by others
-
- Copyright: © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <5> 10/18/96 DM 1393717: incidental ODFrame property
- changes need not dirty draft
- <4> 9/26/96 CC AttachSourceFrame: newFrame must be
- released.
- <3> 5/24/96 jpa 1246074: SOM_CATCH --> SOM_TRY
- <2> .03.1996 NP 1307182: Added Preferences menu handling
- for testing.
-
- To Do:
- In Progress:
-
- */
-
- #ifndef _ALTPOINT_
- #include "AltPoint.h" // Use C++ savvy ODPoint and ODRect
- #endif
-
- #ifndef _ODMEMORY_
- #include "ODMemory.h"
- #endif
-
- #define SOM_Module_drawpart_Source
- #define VARIABLE_MACROS
- #include <DrawPart.xih>
-
- #ifndef _DRWSHARED_
- #include "DrwShared.h"
- #endif
-
- #ifndef _PLFMDEF_
- #include <PlfmDef.h>
- #endif
-
- #ifndef _DRAWOBJ_
- #include "DrawObj.h"
- #endif
-
- #ifndef __EVENTS__
- #include <Events.h> // GetMouse, StillDown.
- #endif
-
- #ifndef __MENUS__
- #include <Menus.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __ICONS__
- #include <Icons.h>
- #endif
-
- #ifndef __PICKER__
- #include <Picker.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h> // HiWord etc.
- #endif
-
- #ifndef __LIMITS__
- #include <limits.h>
- #endif
-
- #ifndef __STDLIB__
- #include <StdLib.h> // Abs
- #endif
-
- #ifndef _STDIO
- #include <stdio.h>
- #endif
-
- #ifndef _STRING
- #include <string.h>
- #endif
-
- #ifndef _STDTYPIO_
- #include "StdTypIO.h"
- #endif
-
- #ifndef _USERSRCM_
- #include "UseRsrcM.h"
- #endif
-
- #ifndef _DOCUTILS_
- #include <DocUtils.h>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Foci_defined
- #include <Foci.xh>
- #endif
-
- #ifndef SOM_ODDragItemIterator_xh
- #include "DgItmIt.xh"
- #endif
-
- #ifndef SOM_Module_OpenDoc_Global_Types_defined
- #include "ODTypesM.xh"
- #endif
-
- #ifndef SOM_ODFocusSet_xh
- #include <FocusSet.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_ODArbitrator_xh
- #include <Arbitrat.xh>
- #endif
-
- #ifndef SOM_ODInfo_xh
- #include <Info.xh>
- #endif
-
- #ifndef _INFOUTIL_
- #include <InfoUtil.h>
- #endif
-
- #ifndef _ISOSTRING_
- #include "ISOStr.h"
- #endif
-
- #ifndef _ITEXT_
- #include <IText.h>
- #endif
-
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
-
- #ifndef __SCRIPT__
- #include <Script.h>
- #endif
-
- #ifndef _ORDCOLL_
- #include "OrdColl.h"
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- #ifndef _EXCEPT_
- #include "Except.h"
- #endif
-
- #ifndef _FOCUSLIB_
- #include "FocusLib.h"
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODFacetIterator_xh
- #include "FacetItr.xh"
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include <Frame.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- #ifndef SOM_ODStorageUnitView_xh
- #include <SUView.xh>
- #endif
-
- #ifndef SOM_ODStorageUnitCursor_xh
- #include <SUCursor.xh>
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- #ifndef SOM_ODDocument_xh
- #include <Document.xh>
- #endif
-
- #ifndef SOM_ODContainer_xh
- #include <ODCtr.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StandardExtensions_defined
- #include <StdExts.xh>
- #endif
-
- #ifndef SOM_ODMenuBar_xh
- #include "MenuBar.xh"
- #endif
-
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- #ifndef SOM_ODWindowState_xh
- #include <WinStat.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- #ifndef SOM_ODFrameFacetIterator_xh
- #include "FrFaItr.xh"
- #endif
-
- #ifndef SOM_DrawSI_xh
- #include "DrawSI.xh"
- #endif
-
- #ifndef _SIHELPER_
- #include <SIHelper.h>
- #endif
-
- #ifndef SOM_ODNameResolver_xh
- #include <NamRslvr.xh>
- #endif
-
- #ifndef _SEUTILS_
- #include "SEUtils.h"
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_ODDragAndDrop_xh
- #include <DragDrp.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdDefs_defined
- #include <StdDefs.xh>
- #endif
-
- #ifndef SOM_ODCanvas_xh
- #include <Canvas.xh>
- #endif
-
- #ifndef _ODUTILS_
- #include <ODUtils.h>
- #endif
-
- #ifndef _PASCLSTR_
- #include "PasclStr.h"
- #endif
-
- #ifndef SOM_ODUndo_xh
- #include <Undo.xh>
- #endif
-
- #ifndef SOM_ODClipboard_xh
- #include <Clipbd.xh>
- #endif
-
- //#ifndef _DFRMITER_
- //#include "DFrmIter.h"
- //#endif
-
- #ifndef SOM_DrawEmbeddedFramesIterator_xh
- #include "DrwEmFrI.xh"
- #endif
-
- #ifndef __GXMATH__
- #include <GXMath.h>
- #endif
-
- #ifndef __STANDARDFILE__
- #include <StandardFile.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef _STORUTIL_
- #include <StorUtil.h>
- #endif
-
- #ifndef _BARRAY_
- #include <BArray.h>
- #endif
-
- #ifndef _WINUTILS_
- #include "WinUtils.h"
- #endif
-
- #ifndef _BNDNSUTL_
- #include <BndNSUtl.h>
- #endif
-
- #ifndef _EDITRSET_
- #include <EditrSet.h>
- #endif
-
- #ifndef _TEMPOBJ_
- #include "TempObj.h"
- #endif
-
- #ifndef _TEMPITER_
- #include "TempIter.h"
- #endif
-
- #ifndef _UTILERRS_
- #include "UtilErrs.h"
- #endif
-
- #ifndef _ODDEBUG_
- #include "ODDebug.h"
- #endif
-
- #pragma segment DrawPart
-
- #if ODDebug
- #define SCRIPTDEBUG 1
- #else
- #undef SCRIPTDEBUG
- #endif
-
- // #define SCRIPTING_OFF
-
- static ODSession* gSession; // For use in Dialog Filter Proc
- static Point gLastPoint;
-
- //==============================================================================
- // Constants
- //==============================================================================
-
- #define kNoBias kODNULL
- #define ODDebugCursor 0 // debug cursor location in MouseEnter etc.
- #define ODDebugConnections 0 // Facet/Frame added and removed
- #define ODDebugActivates 0
- #define ODDebugDrags 0
-
- #define BETASEEDMODS
-
- #define NUKE_PARTSBIN_FOR_DR
-
- #define TESTING_DIALOG_TSMTE 1 /* MAKE SURE THIS IS ONLY DEFINED AS 1 or 0 */
-
- const ODSShort kXMPBorderWidth = 5;
- const ODSShort kODHandleLenMultiplier = 3;
-
- static const RGBColor rgbGray = { 0x7FFF, 0x7FFF, 0x7FFF };
- static const RGBColor rgbRed = { 0xBFFF, 0x7FFF, 0x7FFF };
- static const RGBColor rgbGreen = { 0x7FFF, 0xBFFF, 0x7FFF };
- static const RGBColor rgbYellow = { 0xBFFF, 0xBFFF, 0x7FFF };
- static const RGBColor rgbBlue = { 0x7FFF, 0x7FFF, 0xBFFF };
- static const RGBColor rgbMagenta = { 0xBFFF, 0x7FFF, 0xBFFF };
- static const RGBColor rgbCyan = { 0x7FFF, 0xBFFF, 0xBFFF };
- static const RGBColor rgbWhite = { 0xFFFF, 0xFFFF, 0xFFFF };
- static const RGBColor rgbBlack = { 0x0000, 0x0000, 0x0000 };
-
- const ODSShort kPaletteLeft = 0;
- const ODSShort kPaletteRight = 50;
- const ODSShort kPaletteTop = 0;
- const ODSShort kPaletteBottom = 200;
-
- enum {
- kGray = 0,
- kRed,
- kGreen,
- kYellow,
- kBlue,
- kMagenta,
- kCyan,
- kWhite,
- kOther,
- kNumColors = kOther
- };
-
-
- const ODSShort kMargin = 10;
-
- const short kSuspendResumeMessage = 0x01; // Resume vs. suspend mask
- const short kMouseMovedMessage = 0xFA; // High byte mouse-moved event message
-
- const ODMenuID kDrawColorMenuID = 4;
- const ODMenuID kDrawEmbedMenuID = 5;
- const ODMenuID kDrawFrameMenuID = 6;
-
- //for SCRIPTDEBUG
- const ODMenuID kDrawScriptingMenuID = 7;
-
- // $$$$$ EMBED MENU CRUFT. SHOULD NOT BE HARDCODING OTHER PART KINDS INTO CODE.
- static const ODType kODPartTogglePart = "TogglePart";
- static const ODType kODPartButtonPart = "ButtonPart";
- static const ODType kODPartTextPart = "TextPart";
- static const ODType kODPartDrawPart = "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:Kind:TestDraw";
- static const ODType kODPartMoviePart = "MoviePart";
- static const ODType kODPartClockPart = "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:Kind:TestClock";
- static const ODType kODPartStylPart = "StylPart";
- static const ODType kODPartTestPart = "TestPart";
- static const ODType kODPartDragPart = "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:Kind:TestDrag";
- #ifndef NUKE_PARTSBIN_FOR_DR
- static const ODType kODPartPartsBin = "Apple:Kind:PartsBin";
-
- static const ODPropertyName kODPropPartsBin = "Apple:Property:PartsBin";
- #endif
-
- static const ODPropertyName kODPropEmbeddedFrames = "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:TestDraw:Property:EmbeddedFrames";
- static const ODPropertyName kODPropPrintingInfo = "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:TestDraw:Property:PrintingInfo";
- static const ODPropertyName kPropScriptingOn = "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:TestDraw:Property:ScriptingOn";
- static const ODPropertyName kODPropExternalTransform = "+//ISO 9070/ANSI::113722::US::CI LABS::OpenDoc:Property:ExternalTransform";
-
- //==============================================================================
- // Commands
- //==============================================================================
-
- const ODCommandID cGray = 20001;
- const ODCommandID cRed = 20002;
- const ODCommandID cGreen = 20003;
- const ODCommandID cYellow = 20004;
- const ODCommandID cBlue = 20005;
- const ODCommandID cMagenta = 20006;
- const ODCommandID cCyan = 20007;
- const ODCommandID cWhite = 20008;
- const ODCommandID cOtherColor = 20009;
-
- #if TESTING_DIALOG_TSMTE
- const ODCommandID kODBringUpTestTSMTEDialog = 20016;
- #endif
-
- #ifndef NUKE_PARTSBIN_FOR_DR
- const ODCommandID kODCommandShowPartsBin = 20012;
- #endif
-
- #ifdef SCRIPTDEBUG
- const ODCommandID cToggleScripting = 20015;
- #endif
-
-
- //==============================================================================
- // 'ternalization
- //==============================================================================
-
- static const ODPropertyName kPropFrameInfo = "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:TestDraw:Property:FrameInfo";
-
- static const ODValueType kQDPoint = "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:TestDraw:Type:Point";
- static const ODValueType kTPrintRec = "+//ISO 9070/ANSI::113722::US::CI LABS::MacOS:Type:TPrint Record";
- static const ODValueType kDrawFrameID = "+//ISO 9070/ANSI::113722::US::CI LABS::MacOS:Type:FrameID";
-
- static const ODType kDrawPresNormal = "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:TestDraw:Presentation:Normal";
- static const ODType kDrawPresPalette = "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:TestDraw:Presentation:Palette";
-
- #define kKindTestDraw "+//ISO 9070/ANSI::113722::US::CI LABS::Apple:Kind:TestDraw"
-
- //==============================================================================
- // Function Prototype
- //==============================================================================
-
- pascal Boolean AboutDialogFilter(DialogPtr dialog,
- EventRecord* event,
- short* itemHit);
-
- ODBoolean RGBEqual(RGBColor a,RGBColor b); // Function Prototype for correctness
-
- ODBoolean RGBEqual(RGBColor a,RGBColor b)
- {
- return (a.red == b.red &&
- a.green == b.green &&
- a.blue == b.blue);
- }
-
- ODUShort DetermineNumberOfPagesinDoc(Environment* ev, ODFrame* frame, Rect page);
- ODBoolean ValueOnClipboard(Environment* ev, ODSession* session);
-
- static void ShowMyDragHilite(Environment* ev, ODDragAndDrop* dad, ODFacet* facet);
- static void HideMyDragHilite(Environment* ev, ODDragAndDrop* dad, ODFacet* facet);
- static void CommonInvertFacet(Environment* ev, ODDragAndDrop* dad, ODFacet* facet, boolean show);
-
- //==============================================================================
- // Global Variable
- //==============================================================================
-
- static Proxy* dadSelection;
- static ODFacet* gDragHilitedFacet = kODNULL;
-
- //==============================================================================
- // Finally, the code....
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // DrawPart::GetSemanticInterface
- //------------------------------------------------------------------------------
-
- SOM_Scope DrawSI* SOMLINK AppleTest_ContainerGetSemanticInterface(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","GetSemanticInterface");
-
- SOM_TRY
-
- #ifndef SCRIPTING_OFF
- return _fSemtIntf;
- #else
- return kODNULL;
- #endif
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- // $$$$$ a very temporary hack....
- static short ItemFromClass(DescType theClass)
- {
- short item;
-
- switch(theClass)
- {
- case cDrawPart : item = 1;
- case cDragPart : item = 2;
- case cClockPart : item = 3;
- case cTestPart : item = 4;
- }
-
- return item;
- }
-
- //------------------------------------------------------------------------------
- // DrawPart::CreateNewPart
- //------------------------------------------------------------------------------
-
- SOM_Scope ODPart* SOMLINK AppleTest_ContainerCreateNewPart(AppleTest_Container *somSelf, Environment *ev,
- DescType theClass,
- AEDesc* theLocation)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","CreateNewPart");
-
- SOM_TRY
-
- ODUnused(theLocation);
- OrderedCollectionIterator iter(_fDisplayFrames);
- ODFrame* frame = (ODFrame*)iter.First();
-
- ODPart* theResult;
- somSelf->Embed(ev, ItemFromClass(theClass), frame, &theResult);
- return theResult;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- //------------------------------------------------------------------------------
- // DrawPart::SetNewBounds
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK AppleTest_ContainerSetNewBounds(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame,
- Rect* r)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","SetNewBounds");
-
- SOM_TRY
-
- Proxy* p = somSelf->ProxyForFrame(ev, frame);
-
- Point pt = *(Point*)r;
- p->transform->SetQDOffset(ev, &pt);
-
- Rect rNormalized = *r;
- OffsetRect(&rNormalized, -pt.h, -pt.v);
- ODRect xmpr = rNormalized;
- TempODShape shape = frame->AcquireFrameShape(ev, kODNULL);
- shape->SetRectangle(ev, &xmpr);
-
- ODFrameFacetIterator* fi = frame->CreateFacetIterator(ev);
- for(ODFacet* facet = fi->First(ev); fi->IsNotComplete(ev);
- facet = fi->Next(ev))
- {
- TempODTransform newXform = p->transform->Copy(ev);
- facet->ChangeGeometry(ev, kODNULL, newXform, kODNULL);
- facet->Invalidate(ev, kODNULL, kODNULL);
- }
- delete fi;
-
- frame->ChangeFrameShape(ev, shape, kODNULL);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // DrawPart: CreateFrameProxy
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK AppleTest_ContainerCreateFrameProxy(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame,
- ODTransform* externalTransform)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","CreateFrameProxy");
-
- SOM_TRY
-
- // add the frame to the collection of embedded frames
- frame->Acquire(ev); // DMc bump ref: going into collection
- _fEmbeddedFrames->AddFirst(frame);
-
- // calculate the frame shape's region
- ODShape* shape = frame->AcquireFrameShape(ev, kODNULL);
- ODShape* shapeCopy = shape->Copy(ev);
-
- shapeCopy->Transform(ev, externalTransform);
- RgnHandle shapeRgn = shapeCopy->CopyQDRegion(ev);
-
- shapeCopy->Release(ev); shapeCopy = kODNULL;
- shape->Release(ev); shape = kODNULL;
-
- // create a proxy to hold the embedded frame
- externalTransform->Acquire(ev); // DMc bump ref: going into structure
- Proxy* p = new Proxy(shapeRgn, frame, externalTransform); // new for Facets
-
- // put proxy into contents, possibly adjusting other content
- _fContents->AddFirst(p);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // DrawPart: DeleteFrameProxy
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK AppleTest_ContainerDeleteFrameProxy(AppleTest_Container *somSelf, Environment *ev,
- Proxy* proxy)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DeleteFrameProxy");
-
- SOM_TRY
-
- if ( proxy )
- {
- if ( _fEmbeddedFrames->Contains(proxy->frame) )
- {
- _fEmbeddedFrames->Remove(proxy->frame);
- ODReleaseObject(ev, proxy->frame);
- }
-
- _fContents->Remove(proxy);
-
- proxy->transform->Release(ev); proxy->transform = kODNULL; // DMc - transform is a field
- ODDisposeHandle((Handle)proxy->region);
- delete proxy;
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // DrawPart: ProxyForFrame
- //------------------------------------------------------------------------------
-
- SOM_Scope Proxy* SOMLINK AppleTest_ContainerProxyForFrame(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ProxyForFrame");
-
- SOM_TRY
-
- Proxy* rp = kODNULL;
-
- if (_fEmbeddedFrames->Contains(frame))
- {
- OrderedCollectionIterator i(_fContents);
- Proxy* p;
- for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
- {
- if (p->frame == frame)
- rp = p;
- }
- }
- if (!rp)
- THROW(kODErrInvalidFrame);
-
- return rp;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
-
- /*
- * SOM_Scope void SOMLINK AppleTest_ContainerUpdateProxyRegion(AppleTest_Container *somSelf, Environment *ev,
- * Proxy proxy)
- */
-
- /*
- * The prototype for AppleTest_ContainerUpdateProxyRegion was replaced by the following prototype:
- */
- SOM_Scope void SOMLINK AppleTest_ContainerUpdateProxyRegion(AppleTest_Container *somSelf, Environment *ev,
- Proxy* proxy)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","UpdateProxyRegion");
-
- SOM_TRY
-
- TempODShape scratch = ODCopyAndRelease(ev, proxy->frame->AcquireFrameShape(ev, kODNULL));
- scratch->Transform(ev, proxy->transform);
- RgnHandle scratchRgn = scratch->GetQDRegion(ev);
- CopyRgn(scratchRgn, proxy->region);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerCreateProxySelectionBorder(AppleTest_Container *somSelf, Environment *ev,
- Proxy* p)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","CreateProxySelectionBorder");
-
- SOM_TRY
-
- // -- selection border region --
-
- ODRgnHandle border = ODNewRgn();
- CopyRgn(p->region, border);
- InsetRgn(border, -1, -1);
- DiffRgn(border, p->region, border);
-
- Rect borderRect = (**border).rgnBBox;
- Rect tempRect;
-
- // -- corner region --
-
- RgnHandle cornerHdlRgn = ODNewRgn();
- OpenRgn();
- PenSize(1,1);
-
- // top left handle
- SetRect(&tempRect, borderRect.left-2, borderRect.top-2,
- borderRect.left+3, borderRect.top+3);
- FrameRect(&tempRect);
-
- // top right handle
- SetRect(&tempRect, borderRect.right-3, borderRect.top-2,
- borderRect.right+2, borderRect.top+3);
- FrameRect(&tempRect);
-
- // bottom left handle
- SetRect(&tempRect, borderRect.left-2, borderRect.bottom-3,
- borderRect.left+3, borderRect.bottom+2);
- FrameRect(&tempRect);
-
- // bottom right handle
- SetRect(&tempRect, borderRect.right-3, borderRect.bottom-3,
- borderRect.right+2, borderRect.bottom+2);
- FrameRect(&tempRect);
-
- CloseRgn(cornerHdlRgn);
-
- // -- edge region --
-
- RgnHandle edgeHdlRgn = ODNewRgn();
- OpenRgn();
-
- if ((borderRect.right - borderRect.left) >= 12) {
-
- short hcenter = (borderRect.right + borderRect.left) / 2;
-
- // top middle handle
- SetRect(&tempRect, hcenter-2, borderRect.top-2,
- hcenter+3, borderRect.top+3);
- FrameRect(&tempRect);
-
- // bottom middle handle
- SetRect(&tempRect, hcenter-2, borderRect.bottom-3,
- hcenter+3, borderRect.bottom+2);
- FrameRect(&tempRect);
- }
-
- if ((borderRect.bottom - borderRect.top) >= 12) {
-
- short vcenter = (borderRect.bottom + borderRect.top) / 2;
-
- // left middle handle
- SetRect(&tempRect, borderRect.left-2, vcenter-2,
- borderRect.left+3, vcenter+3);
- FrameRect(&tempRect);
-
- // right middle handle
- SetRect(&tempRect, borderRect.right-3, vcenter-2,
- borderRect.right+2, vcenter+3);
- FrameRect(&tempRect);
- }
-
- CloseRgn(edgeHdlRgn);
-
- // clip by obscuring frames
-
- Proxy* q;
- OrderedCollectionIterator i(_fContents);
- ODBoolean above = true;
- for (q = (Proxy*) i.First(); i.IsNotComplete(); q = (Proxy*) i.Next())
- { if (p == q) {above = false; continue;}
- if (!above) {continue;}
- DiffRgn(border, q->region, border);
- DiffRgn(cornerHdlRgn, q->region, cornerHdlRgn);
- DiffRgn(edgeHdlRgn, q->region, edgeHdlRgn);
- };
-
-
- if ( _fCornerHandleRgn ) ODDisposeHandle((Handle)_fCornerHandleRgn);
- _fCornerHandleRgn = cornerHdlRgn;
- UnionRgn(border, cornerHdlRgn, border);
-
- if ( _fEdgeHandleRgn ) ODDisposeHandle((Handle)_fEdgeHandleRgn);
- _fEdgeHandleRgn = edgeHdlRgn;
- UnionRgn(border, edgeHdlRgn, border);
-
- if ( _fSelectRgn ) ODDisposeHandle((Handle)_fSelectRgn);
- _fSelectRgn = border;
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerInvalidateSelection(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","InvalidateSelection");
-
- SOM_TRY
-
- if ( _fSelectRgn )
- {
- ODShape* selectShape = frame->CreateShape(ev);
- UnionRgn(_fSelectRgn,_fCornerHandleRgn,_fSelectRgn);
- selectShape->SetQDRegion(ev, (RgnHandle)ODCopyHandle((ODHandle)_fSelectRgn));
- frame->Invalidate(ev, selectShape, kODNULL);
- selectShape ->Release(ev);
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerClipEmbeddedFrames(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ClipEmbeddedFrames");
-
- SOM_TRY
-
- ODFrameFacetIterator* facets = frame->CreateFacetIterator(ev);
- for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev);
- facet = facets->Next(ev))
- somSelf->ClipEmbeddedFacets(ev, facet);
- delete facets;
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerCommonInitContainerPart(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","CommonInitDrawPart");
-
- SOM_TRY
-
- _fDisplayFrames = new OrderedCollection;
- _fEmbeddedFrames = new OrderedCollection;
-
- RGBColor random;
- random.red = Random();
- random.green = Random();
- random.blue = Random();
- _fDefaultColor = random;
-
- _fContents = new OrderedCollection;
- _fSelection = new OrderedCollection;
-
- _fSelectRgn = ODNewRgn();
- _fCornerHandleRgn = ODNewRgn();
- _fEdgeHandleRgn = ODNewRgn();
-
- _fColorMenu = NewMenu(kDrawColorMenuID,"\pBackground");
- _fEmbedMenu = NewMenu(kDrawEmbedMenuID,"\pArrange");
- #ifndef BETASEEDMODS
- _fFrameMenu = NewMenu(kDrawFrameMenuID,"\pFrame");
- #endif
-
- #ifndef BETASEEDMODS
- if (!_fColorMenu || !_fFrameMenu)
- #else
- if ( !_fColorMenu || !_fEmbedMenu)
- #endif
- WARN("Error creating menus");
-
- #ifdef SCRIPTDEBUG
- _fScriptingMenu = NewMenu(kDrawScriptingMenuID,"\pScripting");
- if (!_fScriptingMenu) WARN("Error creating scripting menu");
- #endif
-
- _fSession = somSelf->/*ODPersistentObject::*/GetStorageUnit(ev)->GetSession(ev);
- gSession = _fSession;
-
- AppendMenu(_fColorMenu,"\pGray");
- AppendMenu(_fColorMenu,"\pRed");
- AppendMenu(_fColorMenu,"\pGreen");
- AppendMenu(_fColorMenu,"\pYellow");
- AppendMenu(_fColorMenu,"\pBlue");
- AppendMenu(_fColorMenu,"\pMagenta");
- AppendMenu(_fColorMenu,"\pCyan");
- AppendMenu(_fColorMenu,"\pWhite");
- AppendMenu(_fColorMenu,"\pOther…");
-
- AppendMenu(_fEmbedMenu,"\pNon-Standard Insert…");
- #if TESTING_DIALOG_TSMTE
- AppendMenu(_fEmbedMenu,"\pBring up TSMTE Test Dialog…");
- #endif
- #ifndef NUKE_PARTSBIN_FOR_DR
- AppendMenu(_fEmbedMenu,"\pShow Parts Bin");
- #endif
-
- #ifndef BETASEEDMODS
- AppendMenu(_fEmbedMenu,"\pDrag Text");
- AppendMenu(_fEmbedMenu,"\pTime");
-
- AppendMenu(_fFrameMenu,"\pFreeze");
- AppendMenu(_fFrameMenu,"\pDefrost");
- #endif
-
- #ifdef SCRIPTDEBUG
- if (_fScriptingOn) AppendMenu(_fScriptingMenu,"\pTurn Scripting Off");
- else AppendMenu(_fScriptingMenu,"\pTurn Scripting On");
- #endif
-
- _fMenuBar = _fSession->GetWindowState(ev)->CopyBaseMenuBar(ev);
-
- _fMenuBar->AddMenuLast(ev, kDrawEmbedMenuID, _fEmbedMenu, _fPartWrapper);
- _fMenuBar->AddMenuLast(ev, kDrawColorMenuID, _fColorMenu, _fPartWrapper);
- #ifndef BETASEEDMODS
- _fMenuBar->AddMenuLast(ev, kDrawFrameMenuID, _fFrameMenu, _fPartWrapper);
- #endif
-
- #ifdef SCRIPTDEBUG
- _fMenuBar->AddMenuLast(ev, kDrawScriptingMenuID, _fScriptingMenu, _fPartWrapper);
- #endif
-
- _fMenuBar->RegisterCommand(ev, cGray, kDrawColorMenuID, 1);
- _fMenuBar->RegisterCommand(ev, cRed, kDrawColorMenuID, 2);
- _fMenuBar->RegisterCommand(ev, cGreen, kDrawColorMenuID, 3);
- _fMenuBar->RegisterCommand(ev, cYellow, kDrawColorMenuID, 4);
- _fMenuBar->RegisterCommand(ev, cBlue, kDrawColorMenuID, 5);
- _fMenuBar->RegisterCommand(ev, cMagenta, kDrawColorMenuID, 6);
- _fMenuBar->RegisterCommand(ev, cCyan, kDrawColorMenuID, 7);
- _fMenuBar->RegisterCommand(ev, cWhite, kDrawColorMenuID, 8);
- _fMenuBar->RegisterCommand(ev, cOtherColor, kDrawColorMenuID, 9);
-
- #if TESTING_DIALOG_TSMTE
- _fMenuBar->RegisterCommand(ev, kODBringUpTestTSMTEDialog, kDrawEmbedMenuID, 2);
- #endif
- #ifndef NUKE_PARTSBIN_FOR_DR
- // DEPENDS ON THE POSITION OF THE TESTING_DIALOG_TSMTE MENU ITEM
- _fMenuBar->RegisterCommand(ev, kODCommandShowPartsBin, kDrawEmbedMenuID,
- 2 + TESTING_DIALOG_TSMTE);
- #endif
-
- #ifdef SCRIPTDEBUG
- _fMenuBar->RegisterCommand(ev, cToggleScripting, kDrawScriptingMenuID, 1);
- #endif
-
- _fSelectionFocus = _fSession->Tokenize(ev, kODSelectionFocus);
- _fMenuFocus = _fSession->Tokenize(ev, kODMenuFocus);
- _fKeyFocus = _fSession->Tokenize(ev, kODKeyFocus);
- _fClipboardFocus = _fSession->Tokenize(ev, kODClipboardFocus);
-
- #if 1
- // The way it should be
- _fFocusSet = _fSession->GetArbitrator(ev)->CreateFocusSet(ev);
- #else
- // The way it has to be until Richard implements the above:
- _fFocusSet = new ODFocusSet; _fFocusSet->InitFocusSet(ev);
- #endif
- _fFocusSet->Add(ev, _fSelectionFocus);
- _fFocusSet->Add(ev, _fMenuFocus);
- _fFocusSet->Add(ev, _fKeyFocus);
-
- #ifndef SCRIPTING_OFF
- _fSemtIntf = new DrawSI;
- SIHelper* semItfcHelper = new SIHelper;
- semItfcHelper->InitSIHelper(_fSession, _fSemtIntf);
- _fSemtIntf->InitCPlusSemanticInterface(ev, somSelf, semItfcHelper, _fSession);
-
- somSelf->InstallObjectAccessors(ev);
- #endif
-
- ODQDGlobals.randSeed = TickCount();
-
- somSelf->LoadIcons(ev);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerLoadIcons(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","LoadIcons");
-
- SOM_TRY
-
- ODSLong savedRefNum;
- BeginUsingLibraryResources(savedRefNum);
-
- Handle largesuite;
- OSErr osr = NewIconSuite(&largesuite);
- THROW_IF_ERROR(osr,"Error creating icon suite");
-
- Handle icon = GetResource('icl8',90);
- THROW_IF_ERROR(ResError(),"Trouble loading icons (icl8)");
- DetachResource(icon);
- osr = AddIconToSuite(icon,largesuite,'icl8');
-
- icon = GetResource('icl4',90);
- THROW_IF_ERROR(ResError(),"Trouble loading icons (icl4)");
- DetachResource(icon);
- osr = AddIconToSuite(icon,largesuite,'icl4');
-
- icon = GetResource('ICN#',90);
- THROW_IF_ERROR(ResError(),"Trouble loading icons (ICN#)");
- DetachResource(icon);
- osr = AddIconToSuite(icon,largesuite,'ICN#');
-
- if (largesuite) _fLargeIcons = largesuite;
-
- Handle smallsuite;
- osr = NewIconSuite(&smallsuite);
- THROW_IF_ERROR(osr,"Error creating icon suite");
-
- icon = GetResource('ics8',90);
- THROW_IF_ERROR(ResError(),"Trouble loading icons (ics8)");
- DetachResource(icon);
- osr = AddIconToSuite(icon,smallsuite,'ics8');
-
- icon = GetResource('ics4',90);
- THROW_IF_ERROR(ResError(),"Trouble loading icons (ics4)");
- DetachResource(icon);
- osr = AddIconToSuite(icon,smallsuite,'ics4');
-
- icon = GetResource('ics#',90);
- THROW_IF_ERROR(ResError(),"Trouble loading icons (ics#)");
- DetachResource(icon);
- osr = AddIconToSuite(icon,smallsuite,'ics#');
-
- if (smallsuite) _fSmallIcons = smallsuite;
-
- EndUsingLibraryResources(savedRefNum);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerRelease(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","Release");
-
- SOM_TRY
-
- parent_Release(somSelf, ev);
- if (somSelf->GetRefCount(ev) == 0)
- somSelf->GetStorageUnit(ev)->GetDraft(ev)->ReleasePart(ev, _fPartWrapper);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerReleaseAll( AppleTest_Container *somSelf,
- Environment *ev )
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ReleaseAll");
-
- SOM_TRY
-
- #ifndef SCRIPTING_OFF
- if (_fSemtIntf != kODNULL)
- {
- delete ((SIHelper*)_fSemtIntf->GetSIHelper(ev));
- ODFinalReleaseObject(ev, _fSemtIntf);
- }
- #endif
-
- Proxy* p;
- ODFrame* frame;
-
- somSelf->HidePalette(ev);
- frame = (ODFrame*) _fDisplayFrames->First();
- while (frame != kODNULL) {
- _fDisplayFrames->Remove(frame);
- ODReleaseObject(ev,frame);
- frame = (ODFrame*) _fDisplayFrames->First();
- }
- frame = (ODFrame*) _fEmbeddedFrames->First();
- while (frame != kODNULL) {
- p = somSelf->ProxyForFrame(ev, frame);
- _fContents->Remove(p);
- _fEmbeddedFrames->Remove(frame);
- ODReleaseObject(ev,frame);
- frame = (ODFrame*) _fEmbeddedFrames->First();
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerInstallObjectAccessors(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","InstallObjectAccessors");
-
- SOM_TRY
-
- InstallStaticCallbacks( _fSemtIntf, (SIHelper*)_fSemtIntf->GetSIHelper(ev),
- _fSession );
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // AppleTest_ContainerGetEmbeddedFrames
- //------------------------------------------------------------------------------
-
- SOM_Scope OrderedCollection* SOMLINK AppleTest_ContainerGetEmbeddedFrames(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","GetEmbeddedFrames");
-
- SOM_TRY
-
- return _fEmbeddedFrames;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- //------------------------------------------------------------------------------
- // AppleTest_ContainerGetDisplayFrames
- //------------------------------------------------------------------------------
-
- SOM_Scope OrderedCollection* SOMLINK AppleTest_ContainerGetDisplayFrames(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","GetDisplayFrames");
-
- SOM_TRY
-
- return _fDisplayFrames;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- SOM_Scope Proxy* SOMLINK AppleTest_ContainerProxyForFrameID(AppleTest_Container *somSelf, Environment *ev,
- ODID frameID)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ProxyForFrameID");
-
- SOM_TRY
-
- ODFrame* frame = somSelf->GetStorageUnit(ev)->GetDraft(ev)->AcquireFrame(ev, frameID);
- Proxy* p = somSelf->ProxyForFrame(ev, frame);
- frame->Release(ev);
- return p;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerHighlightSelection(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HighlightSelection");
-
- SOM_TRY
-
- switch (_fSelection->Count())
- {
- case 0: // no selection
- break;
-
- case 1: // single selection
- { OrderedCollectionIterator i(_fSelection);
- somSelf->HighlightProxyBorder(ev, (Proxy*) i.First());
- };
- break;
-
- default: // multiple selection
- { Proxy* p;
- OrderedCollectionIterator i(_fSelection);
- for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
- { if (_fSelection->Contains(p))
- somSelf->HighlightContentObject(ev, p);
- }
- }
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerHighlightProxyBorder(AppleTest_Container *somSelf, Environment *ev,
- Proxy* p)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HighlightProxyBorder");
-
- SOM_TRY
-
- ODUnused(p);
-
- if ( _fSelectRgn )
- {
- // draw frame border
- #ifdef THINK_CPLUS
- FillRgn(_fSelectRgn, ODQDGlobals.gray);
- FillRgn(_fCornerHandleRgn, ODQDGlobals.black);
- FillRgn(_fEdgeHandleRgn, ODQDGlobals.black);
- #else
- FillRgn(_fSelectRgn, &(ODQDGlobals.gray));
- FillRgn(_fCornerHandleRgn, &(ODQDGlobals.black));
- FillRgn(_fEdgeHandleRgn, &(ODQDGlobals.black));
- #endif
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerHighlightContentObject(AppleTest_Container *somSelf, Environment *ev,
- Proxy* p)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HighlightContentObject");
-
- SOM_TRY
-
- ODUnused(p);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerClipEmbeddedFacets(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* facet)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ClipEmbeddedFacets");
-
- SOM_TRY
-
- ODGeometryMode geoMode = GetCanvasGeometryMode(ev, facet->GetCanvas(ev));
-
- ODShape* shape;
- if ( facet->GetFrame(ev)->IsRoot(ev) )
- shape = facet->GetFrame(ev)->AcquireFrameShape(ev, kODNULL);
- else
- shape = facet->AcquireClipShape(ev, kODNULL);
-
- ODShape* workingClip = ODCopyAndRelease(ev, shape);
- workingClip->SetGeometryMode(ev,geoMode);
-
- // let selection obscure embedded parts
-
- RgnHandle tempRgn;
- ODShape* tempShape = workingClip->NewShape(ev);
-
- if (_fSelectRgn && !EmptyRgn(_fSelectRgn))
- {
- tempRgn = ODNewRgn();
- CopyRgn(_fSelectRgn, tempRgn);
- tempShape->SetPlatformShape(ev, kODQuickDraw, tempRgn);
- workingClip->Subtract(ev, tempShape);
- }
-
- if (_fCornerHandleRgn && !EmptyRgn(_fCornerHandleRgn))
- {
- tempRgn = ODNewRgn();
- CopyRgn(_fCornerHandleRgn, tempRgn);
- tempShape->SetPlatformShape(ev, kODQuickDraw, tempRgn);
- workingClip->Subtract(ev, tempShape);
- }
-
- if (_fEdgeHandleRgn && !EmptyRgn(_fEdgeHandleRgn))
- {
- tempRgn = ODNewRgn();
- CopyRgn(_fEdgeHandleRgn, tempRgn);
- tempShape->SetPlatformShape(ev, kODQuickDraw, tempRgn);
- workingClip->Subtract(ev, tempShape);
- }
-
- tempShape->Release(ev);
-
- ODFacet* embFacet;
- ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
- for (embFacet = facets->First(ev);
- facets->IsNotComplete(ev);
- embFacet = facets->Next(ev))
- {
- TempODShape newClipShape = ODCopyAndRelease(ev, embFacet->GetFrame(ev)->AcquireFrameShape(ev, kODNULL));
- newClipShape->SetGeometryMode(ev,geoMode);
- TempODShape newMaskShape = ODCopyAndRelease(ev, embFacet->GetFrame(ev)->AcquireUsedShape(ev, kODNULL));
-
- TempODTransform wclipTrans = embFacet->AcquireExternalTransform(ev, kODNULL);
-
- newClipShape->Transform(ev, wclipTrans); // now in containing frame coordinates
- newClipShape->Intersect(ev, workingClip);
- newClipShape->InverseTransform(ev, wclipTrans); // now in embedded frame coordinates
- embFacet->ChangeGeometry(ev, newClipShape, kODNULL, kODNULL);
-
- // Comment out these two lines and newMaskShape above to test #1243157
- newMaskShape->Transform(ev, wclipTrans); // now in containing frame coordinates
- workingClip->Subtract(ev, newMaskShape);
-
- }
- delete facets;
-
- // loop to clip for part content here
-
- workingClip->Release(ev);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerEmptySelection(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","EmptySelection");
-
- SOM_TRY
-
- for(ODULong i = _fSelection->Count(); i > 0; i--)
- {
- Proxy* sp = (Proxy*) _fSelection->RemoveFirst();
- // Don't unselect facets unless the frame is still embedded in this part. [cc]
- // The frame may have been moved to another part.
- TempODFrame tempFrame = sp->frame->AcquireContainingFrame(ev);
- TempODPart tempPart = tempFrame->AcquirePart(ev);
- if ( tempPart == _fPartWrapper )
- {
- ODFrameFacetIterator* facets = sp->frame->CreateFacetIterator(ev);
- for (ODFacet* f1 = facets->First(ev); facets->IsNotComplete(ev); f1 = facets->Next(ev))
- {
- if ( f1->IsSelected(ev) )
- {
- f1->SetSelected(ev, kODFalse);
- }
- }
- delete facets;
- }
- }
- SetEmptyRgn(_fSelectRgn);
- SetEmptyRgn(_fCornerHandleRgn);
- SetEmptyRgn(_fEdgeHandleRgn);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerHandleMouseDown(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* facet,
- ODPoint* where,
- ODEventData* event)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HandleMouseDown");
-
- SOM_TRY
-
- #if defined(ODDebug) && ODDebugActivates
- somPrintf("Draw %d::MouseDown: Calling IsActive\n", somSelf->GetID(ev));
- #endif
- if (!facet->GetWindow(ev)->IsActive(ev))
- {
- #if defined(ODDebug) && ODDebugActivates
- somPrintf("Draw %d::Mouse Down: Calling Select\n", somSelf->GetID(ev));
- #endif
- //facet->GetWindow(ev)->Select(ev);
- }
- else
- somSelf->ActivateFrame(ev, facet->GetFrame(ev));
-
- Point mouse;
- { TempODTransform xForm = facet->AcquireWindowContentTransform(ev, kODNULL);
- ODPoint inv = *where;
- xForm->InvertPoint(ev, &inv);
- mouse = inv.AsQDPoint();
- }
-
- if (facet->GetWindow(ev) == _fPalette)
- {
- RgnHandle bRgn;
- { TempODShape frameShape = facet->GetFrame(ev)->AcquireFrameShape(ev, kODNULL);
- bRgn = frameShape->GetQDRegion(ev);
- }
-
- Rect bRect;
- ODUShort height;
- ODUShort whichColor;
- ODBoolean didHitMargin;
-
- bRect.left = (**bRgn).rgnBBox.left;
- bRect.top = (**bRgn).rgnBBox.top;
- bRect.bottom = (**bRgn).rgnBBox.bottom;
- bRect.right = (**bRgn).rgnBBox.right;
- height = ((bRect.bottom - bRect.top) - kMargin - ((kNumColors-1) * kMargin) - kMargin) / kNumColors;
-
- whichColor = mouse.v / (kMargin + height);
- didHitMargin = ((mouse.v % (kMargin + height)) < kMargin) ||
- (mouse.h < kMargin) ||
- ((mouse.h + kMargin) > bRect.right);
-
- if (didHitMargin == kODFalse) {
- OrderedCollectionIterator aIter(_fDisplayFrames);
-
- ODFrame* displayFrame;
- for (displayFrame = (ODFrame*) aIter.First(); aIter.IsNotComplete(); displayFrame = (ODFrame*) aIter.Next())
- {
- ODFrameFacetIterator* facets = displayFrame->CreateFacetIterator(ev);
- for (ODFacet* facet = (ODFacet*) facets->First(ev);
- facets->IsNotComplete(ev);
- facet = (ODFacet*) facets->Next(ev))
- {
- if (facet->GetWindow(ev) != _fPalette)
- {
- somSelf->SetBGColor1(ev, displayFrame, whichColor);
- displayFrame->Invalidate(ev, kODNULL, kODNULL);
- }
- }
- delete facets;
- }
- }
- }
- else {
-
- OrderedCollectionIterator i(_fSelection);
- Proxy* p = (Proxy*)i.First();
-
- Point qdWhere = where->AsQDPoint();
-
- if (_fSelection->Count() != 0)
- {
- if (PtInRgn(mouse, _fCornerHandleRgn))
- return somSelf->HandleMouseDownCornerResize(ev, facet, p, &mouse);
- else if (PtInRgn(mouse, _fEdgeHandleRgn))
- return somSelf->HandleMouseDownEdgeResize(ev, facet, p, &mouse);
- else if (PtInRgn(mouse, _fSelectRgn))
- return somSelf->HandleMouseDownDrag(ev, facet, p, event);
- else
- switch (_fSelection->Count())
- {
- case 0:
- break;
-
- case 1:
- somSelf->InvalidateSelection(ev, facet->GetFrame(ev));
- somSelf->EmptySelection(ev);
- somSelf->ClipEmbeddedFrames(ev, facet->GetFrame(ev));
- break;
-
- default:
- // !!! handle multiple selection
- break;
- }
- }
- else
- {
- if (!_fDrawingLines && (event->modifiers & controlKey))
- {
- somSelf->StartDrawingLines(ev, facet->GetFrame(ev));
- gLastPoint = mouse;
- }
- }
- }
-
- return kODTrue;
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerHandleBGMouseDown(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* facet,
- ODPoint* where,
- ODEventData* event)
- {
- /* When handling a background mouse-down, I'm interested only in handling drags
- of selected frames. */
-
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HandleBGMouseDown");
-
- SOM_TRY
-
- if (facet->GetWindow(ev) == _fPalette)
- return kODFalse;
- if( _fSelection->Count() != 1 ) // Container doesn't handle multiple drags.
- return kODFalse;
-
- Point mouse;
- { TempODTransform xForm = facet->AcquireWindowContentTransform(ev, kODNULL);
- ODPoint inv = *where;
- xForm->InvertPoint(ev, &inv);
- mouse = inv.AsQDPoint();
- }
-
- if( ! PtInRgn(mouse,_fSelectRgn) )
- return kODFalse;
-
- OrderedCollectionIterator i(_fSelection);
- Proxy* p = (Proxy*)i.First();
- return somSelf->HandleMouseDownDrag(ev, facet, p, event);
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- return kODFalse;
- }
-
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerHandleMouseDownDrag(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* facet,
- Proxy* selection,
- ODEventData* event)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HandleMouseDownDrag");
-
- SOM_TRY
-
- ODSLong savedRefNum;
- BeginUsingLibraryResources(savedRefNum);
- SetCursor(*GetCursor(284)); // Closed Hand Cursor
- EndUsingLibraryResources(savedRefNum);
-
-
- ODBoolean handled = kODFalse;
- ODPart* destPart;
- ODShape* scratch;
- ODPoint translation (0,0);
- Point mdOffset = {0,0};
- RgnHandle dragRgn, tempRgn;
- ODDragAndDrop* dad;
- ODStorageUnit* unit;
- ODDropResult dropResult;
-
- // Build the drag outline
- ODShape* frameShape = selection->frame->AcquireFrameShape(ev, kODNULL);
- scratch = frameShape->Copy(ev);
- frameShape->Release(ev); frameShape = kODNULL;
- scratch->Transform(ev, selection->transform);
- dragRgn = scratch->CopyQDRegion(ev);
-
- Point QDtranslation;
- { TempODTransform wfTrans = facet->AcquireWindowFrameTransform(ev, kODNULL);
- wfTrans->TransformPoint(ev, &translation);
- QDtranslation = translation.AsQDPoint();
- }
-
- LocalToGlobal(&QDtranslation);
- OffsetRgn(dragRgn, QDtranslation.h, QDtranslation.v);
- tempRgn = ODNewRgn();
- CopyRgn(dragRgn, tempRgn);
- InsetRgn(tempRgn, 1, 1);
- DiffRgn(dragRgn, tempRgn, dragRgn);
- ODDisposeHandle((Handle)tempRgn);
- scratch->Release(ev); scratch = kODNULL;
-
- // ••• Fill DAD SU with Props n' Vals
-
- dad = _fSession->GetDragAndDrop(ev);
- dad->Clear(ev);
- unit = dad->GetContentStorageUnit(ev);
-
- // • if dragging one frame, create the content frame property
- // This property cannot be promised, and must be written after the embedded part
- ODSUAddPropValue(ev, unit, kODPropContentFrame, kODStrongStorageUnitRef);
-
- // • if dragging one frame, clone the embedded part into the root storage unit
- // if the embedded part is savy, it will notice the kODPropContentFrame property
- // and promise its content
- ODDraft* fromDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
- ODDraft* toDraft = unit->GetDraft(ev);
- ODDraftKey key = 0;
- ODID toRootID = 0;
- ODID toFrameID = 0;
- TRY
- key = fromDraft->BeginClone(ev, toDraft, kODNULL, kODCloneCut); // May use cut or copy
- // Clone the embedded part to the root storage unit of the drag and drop container
- TempODPart tempPart = selection->frame->AcquirePart(ev);
- toRootID = fromDraft->Clone(ev, key, tempPart->GetID(ev), unit->GetID(ev), selection->frame->GetID(ev));
- // Clone the embedded frame to any storage unit; must be done after cloning the part because
- // the embedded frame strongly references the part.
- toFrameID = fromDraft->Clone(ev, key, selection->frame->GetID(ev), 0, selection->frame->GetID(ev));
- fromDraft->EndClone(ev, key);
- CATCH_ALL
- WARN("Draw: Clone to drag-and-drop container failed");
- if (key != 0)
- fromDraft->AbortClone(ev, key);
- RERAISE;
- ENDTRY
-
- if ( toFrameID )
- {
- ODSetWeakSURefProp(ev, unit, kODPropContentFrame, kODWeakStorageUnitRef, toFrameID);
- // Weakly reference the frame so it must be explicitly cloned into the receiving draft
- }
-
- // • (optional) save offset between mousedown pt and topLeft pt of selection
-
- Point topLeft;
- { TempODFrameFacetIterator faceti(ev,selection->frame);
- TempODTransform wfTrans = faceti.Current()->AcquireWindowFrameTransform(ev, kODNULL);
- topLeft = wfTrans->GetQDOffset(ev);
- }
-
- mdOffset = event->where;
- GlobalToLocal(&mdOffset);
-
- SubPt(topLeft,&mdOffset);
-
- unit->AddProperty(ev, kODPropMouseDownOffset);
- StorageUnitSetPromiseValue(unit, ev, kQDPoint, 0, sizeof(Point)/2, (ODValue) &(mdOffset.v), _fPartWrapper);
- StorageUnitSetPromiseValue(unit, ev, kQDPoint, sizeof(Point)/2, sizeof(Point)/2, (ODValue) &(mdOffset.h), _fPartWrapper);
-
- // • (optional) if dragging one frame, save its external transform (not aggregate)
- // $$$$$ Should use StdTypIO to do portable streaming of "point"
- ODSUAddPropValue(ev, unit, kODPropExternalTransform, kQDPoint);
- StorageUnitSetValue(unit, ev, sizeof(Point), (ODValue) &topLeft);
-
- // • if dragging one frame, write its shape [jpa]
- unit->AddProperty(ev, kODPropSuggestedFrameShape);
- TempODShape tempShape = selection->frame->AcquireFrameShape(ev, kODNULL);
- tempShape->WriteShape(ev, unit);
-
- // Write out the dragged frame's ID in case it is dropped back to this part.
- unit->AddProperty(ev, kPropFrameInfo);
- StorageUnitSetPromiseValue(unit, ev, kDrawFrameID, 0, sizeof(ODID), &selection, _fPartWrapper);
-
- // Just to test whether GetPromiseValue works
- {
- const ODULong kBufferSize = 255;
- ODByteArray ba;
- ODPart* part = kODNULL;
- ODULong length = unit->GetPromiseValue(ev, kDrawFrameID, 0, kBufferSize, &ba, &part);
- if ((length != sizeof(ODID)) || (part != _fPartWrapper)) {
- WARN("GetPromiseValue fails!");
- }
- ODDisposePtr(ba._buffer);
- }
-
- dadSelection = selection;
-
- selection->frame->SetDragging(ev, kODTrue);
-
- ODByteArray dragRgnBA = CreateByteArrayStruct(&dragRgn, sizeof(RgnHandle));
- ODByteArray eventBA = CreateByteArrayStruct(&event, sizeof(ODEventData*));
- selection->frame->SetInLimbo(ev, kODTrue);
- dropResult = dad->StartDrag(ev, facet->GetFrame(ev), kODDragImageRegionHandle,
- &dragRgnBA, &destPart, &eventBA);
- DisposeByteArrayStruct(dragRgnBA);
- DisposeByteArrayStruct(eventBA);
-
- dadSelection = kODNULL;
-
- if ( dropResult != kODDropMove )
- selection->frame->SetInLimbo(ev, kODFalse);
-
- if ( (dropResult == kODDropCopy) || (dropResult == kODDropMove) )
- {
- if (destPart == _fPartWrapper)
- {
- // The frame was dropped within the same part
- if (dropResult == kODDropMove)
- facet->GetFrame(ev)->Invalidate(ev, kODNULL, kODNULL);
- selection->frame->SetDragging(ev, kODFalse);
- }
- else if (dropResult == kODDropMove)
- {
- #if ODDebug
- somPrintf("Draw %d::Drag: Cleaning up after move\n", somSelf->GetID(ev));
- #endif
- // The frame was moved out
- facet->GetFrame(ev)->Invalidate(ev, kODNULL, kODNULL);
- // $$$$$ Doesn't invalidating the containing frame make the next line unnecessary
- somSelf->InvalidateSelection(ev, selection->frame); // $$$$$ The frame has been moved elsewhere
- somSelf->EmptySelection(ev);
-
- OrderedCollection* tempFacets = new OrderedCollection;
-
- #if ODDebug
- somPrintf("Draw %d::Drag: Deleting old facets\n", somSelf->GetID(ev));
- #endif
- // Get all facets displaying the moved frame
- // Necessary because they can't be deleted during iteration
- // We can't use the frame's facet iterator because the destination
- // of the move will have changed the frame's containing frame,
- // which eliminates all facets.
- ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
- for (ODFacet* f1 = facets->First(ev);
- facets->IsNotComplete(ev);
- f1 = facets->Next(ev))
- {
- if ( f1->GetFrame(ev) == selection->frame )
- tempFacets->AddLast(f1);
- }
- delete facets;
-
- // Now delete all facets displaying the moved frame
- OrderedCollectionIterator t(tempFacets);
- for (ODFacet* f2 = (ODFacet*)t.First();
- t.IsNotComplete();
- f2 = (ODFacet*)t.Next())
- {
- #if ODDebug
- somPrintf("Draw:: Deleting facet displaying moved frame\n");
- #endif
- f2->GetContainingFacet(ev)->RemoveFacet(ev, f2);
- ODDeleteObject(f2);
- }
- delete tempFacets;
-
- ODFrame* movedFrame = selection->frame;
-
- #if ODDebug
- somPrintf("Draw %d::Drag: Deleting old proxy\n", somSelf->GetID(ev));
- #endif
- movedFrame->Acquire(ev); // So that when we Remove/Release it below, we are using a valid pointer
-
- // Remove our proxy for the moved frame
- somSelf->DeleteFrameProxy(ev, selection); // NOTE: this implicitly releases movedFrame!
-
- if ( movedFrame->IsInLimbo(ev) )
- {
- movedFrame->SetContainingFrame(ev, kODNULL); // force close of part windows
- movedFrame->Remove(ev);
- }
- else
- movedFrame->Release(ev);
- movedFrame = kODNULL;
-
- #if ODDebug
- somPrintf("Draw %d::Drag: Resetting cliping\n", somSelf->GetID(ev));
- #endif
- // Reset clipping of the remaining embedded facets
- somSelf->ClipEmbeddedFrames(ev, facet->GetFrame(ev));
-
- somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
- }
- else
- {
- // The frame was copied
- selection->frame->SetDragging(ev, kODFalse);
- }
-
- handled = kODTrue;
- }
- else // dropResult == kODDropFail
- {
- selection->frame->SetDragging(ev, kODFalse);
- }
- ODDisposeHandle((Handle)dragRgn);
- ODReleaseObject(ev, destPart);
-
- return handled;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerHandleMouseDownEdgeResize(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* facet,
- Proxy* selection,
- Point* mouse)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HandleMouseDownEdgeResize");
-
- SOM_TRY
-
- enum edge {kNone, kTE, kLE, kBE, kRE};
- edge growEdge = kNone;
-
- Rect* sr = somSelf->GetSelectionRectLocal(ev, selection);
-
- if (mouse->v <= ((*sr).top + (0.1 * (*sr).top))) growEdge = kTE;
- else if (mouse->h <= ((*sr).left + (0.1 * (*sr).left))) growEdge = kLE;
- else if (mouse->v >= ((*sr).bottom - (0.1 * (*sr).bottom))) growEdge = kBE;
- else if (mouse->h >= ((*sr).right - (0.1 * (*sr).right))) growEdge = kRE;
-
- somSelf->SetGrafPortOrigin(ev, facet);
- Rect growBox = (*sr);
- Rect oldBox = {0,0,0,0};
- delete sr; sr = kODNULL;
-
- PenMode(patXor);
- #ifdef THINK_CPLUS
- PenPat(ODQDGlobals.gray);
- #else
- PenPat(&(ODQDGlobals.gray));
- #endif
-
- Point theLoc = {0,0};
- Point lastLoc = {0,0};
-
- while (StillDown())
- {
- GetMouse(&theLoc);
-
- if ((theLoc.h != lastLoc.h) || (theLoc.v != lastLoc.v))
- {
- switch (growEdge)
- {
- case kTE:
- growBox.top = theLoc.v;
- break;
-
- case kLE:
- growBox.left = theLoc.h;
- break;
-
- case kBE:
- growBox.bottom = theLoc.v;
- break;
-
- case kRE:
- growBox.right = theLoc.h;
- break;
-
- default:
- break;
- }
- FrameRect(&oldBox);
- FrameRect(&growBox);
- }
-
- lastLoc = theLoc;
- oldBox = growBox;
- }
-
- FrameRect(&oldBox);
-
- #ifdef THINK_CPLUS
- PenPat(ODQDGlobals.gray);
- #else
- PenPat(&(ODQDGlobals.gray));
- #endif
- PenMode(patCopy);
-
- SetOrigin(0,0);
-
- Point delta;
- delta.h = theLoc.h - mouse->h; //where.h;
- delta.v = theLoc.v - mouse->v; //where.v;
- Point transOffset = { 0, 0 };
-
- TempODShape oldShape = selection->frame->AcquireFrameShape(ev, kODNULL);
- ODRect newBounds;
- oldShape->GetBoundingBox(ev, &newBounds);
-
- switch (growEdge)
- {
- case kTE:
- newBounds.bottom -= ff(delta.v);
- transOffset.v += delta.v;
- break;
-
- case kLE:
- newBounds.right -= ff(delta.h);
- transOffset.h += delta.h;
- break;
-
- case kBE:
- newBounds.bottom += ff(delta.v);
- break;
-
- case kRE:
- newBounds.right += ff(delta.h);
- break;
-
- default:
- break;
- }
-
- TempODShape newShape = oldShape->NewShape(ev);
- newShape->SetRectangle(ev, &newBounds);
-
- somSelf->InvalEmbedFrameAfterResize(ev, facet, selection, oldShape, newShape, &transOffset);
-
- return kODTrue;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerHandleMouseDownCornerResize(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* facet,
- Proxy* selection,
- Point* mouse)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HandleMouseDownCornerResize");
-
- SOM_TRY
-
- enum corner {kNone, kTL, kTR, kBL, kBR};
- corner growCorner = kNone;
-
- Rect* sr = somSelf->GetSelectionRectLocal(ev, selection);
- Point center;
- SetPt(¢er, ((*sr).right + (*sr).left) / 2, ((*sr).bottom + (*sr).top) / 2); // center of FrameShape
-
- if ((mouse->v <= center.v) && (mouse->h <= center.h)) growCorner = kTL;
- else if ((mouse->v < center.v) && (mouse->h > center.h)) growCorner = kTR;
- else if ((mouse->v > center.v) && (mouse->h < center.h)) growCorner = kBL;
- else if ((mouse->v > center.v) && (mouse->h > center.h)) growCorner = kBR;
-
- somSelf->SetGrafPortOrigin(ev, facet);
- Rect growBox = (*sr);
- Rect oldBox = {0,0,0,0};
- delete sr; sr = kODNULL;
-
- PenMode(patXor);
- #ifdef THINK_CPLUS
- PenPat(ODQDGlobals.gray);
- #else
- PenPat(&(ODQDGlobals.gray));
- #endif
-
- Point theLoc = {0,0};
- Point lastLoc = {0,0};
-
- while (StillDown())
- {
- GetMouse(&theLoc);
-
- if ((theLoc.h != lastLoc.h) || (theLoc.v != lastLoc.v))
- {
- switch (growCorner)
- {
- case kTL:
- growBox.top = theLoc.v;
- growBox.left = theLoc.h;
- break;
-
- case kTR:
- growBox.top = theLoc.v;
- growBox.right = theLoc.h;
- break;
-
- case kBL:
- growBox.left = theLoc.h;
- growBox.bottom = theLoc.v;
- break;
-
- case kBR:
- growBox.bottom = theLoc.v;
- growBox.right = theLoc.h;
- break;
-
- default:
- break;
- }
-
- FrameRect(&oldBox);
- FrameRect(&growBox);
- }
-
- lastLoc = theLoc;
- oldBox = growBox;
- }
-
- FrameRect(&oldBox);
-
- #ifdef THINK_CPLUS
- PenPat(ODQDGlobals.gray);
- #else
- PenPat(&(ODQDGlobals.gray));
- #endif
- PenMode(patCopy);
-
- SetOrigin(0,0);
-
- Point delta;
- delta.h = theLoc.h - mouse->h; //where.h;
- delta.v = theLoc.v - mouse->v; //where.v;
- Point transOffset = { 0, 0 };
-
- TempODShape oldShape = selection->frame->AcquireFrameShape(ev, kODNULL);
- ODRect newBounds;
- oldShape->GetBoundingBox(ev, &newBounds);
- ODPoint fixDelta = delta;
-
- switch (growCorner)
- {
- case kTL:
- newBounds.bottom -= fixDelta.y; newBounds.right -= fixDelta.x;
- transOffset.v += delta.v; transOffset.h += delta.h;
- break;
-
- case kTR:
- newBounds.bottom -= fixDelta.y; newBounds.right += fixDelta.x;
- transOffset.v += delta.v;
- break;
-
- case kBL:
- newBounds.bottom += fixDelta.y; newBounds.right -= fixDelta.x;
- transOffset.h += delta.h;
- break;
-
- case kBR:
- newBounds.bottom += fixDelta.y;
- newBounds.right += fixDelta.x;
- break;
-
- default:
- break;
- }
-
- TempODShape newShape = oldShape->NewShape(ev);
- newShape->SetRectangle(ev, &newBounds);
-
- somSelf->InvalEmbedFrameAfterResize(ev, facet, selection, oldShape, newShape, &transOffset);
-
- return kODTrue;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerHandleMouseDownInEmbeddedFrame(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* container,
- ODFacet* facet,
- ODPoint* where,
- ODEventData* event)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HandleMouseDownInEmbeddedFrame");
-
- SOM_TRY
-
- ODUnused(where);
- ODUnused(event);
-
- ODBoolean result = (event->what != kODEvtBGMouseDownEmbedded);
-
- Proxy* p = somSelf->ProxyForFrame(ev, facet->GetFrame(ev));
-
- switch (_fSelection->Count())
- {
- case 0:
- if( event->what == kODEvtBGMouseDownEmbedded )
- break;
- _fSelection->AddFirst((ElementType)p);
- facet->SetSelected(ev, kODTrue);
- somSelf->CreateProxySelectionBorder(ev, p);
- somSelf->ClipEmbeddedFrames(ev, container->GetFrame(ev));
- somSelf->InvalidateSelection(ev, container->GetFrame(ev));
- container->GetWindow(ev)->Update(ev);
- if ( WaitMouseMoved(event->where) )
- {
- somSelf->HandleMouseDownDrag(ev, container, p, event);
- result = kODTrue;
- }
- else
- {
- }
- break;
-
- case 1:
- if ( WaitMouseMoved(event->where) )
- {
- somSelf->HandleMouseDownDrag(ev, container, p, event);
- result = kODTrue;
- }
- else
- {
- #if defined(ODDebug) && ODDebugActivates
- somPrintf("Draw %d::Mouse Down Embedded: Calling IsActive\n", somSelf->GetID(ev));
- #endif
- if (!container->GetWindow(ev)->IsActive(ev))
- {
- #if defined(ODDebug) && ODDebugActivates
- somPrintf("Draw %d::Mouse Down Embedded: Calling Select\n", somSelf->GetID(ev));
- #endif
- container->GetWindow(ev)->Select(ev);
- }
- else
- somSelf->ActivateFrame(ev, container->GetFrame(ev));
-
- if( event->what == kODEvtBGMouseDownEmbedded )
- break;
- ODBoolean wasSelected = facet->IsSelected(ev);
-
- somSelf->InvalidateSelection(ev, container->GetFrame(ev));
- somSelf->EmptySelection(ev);
-
- if ( !wasSelected )
- {
- _fSelection->AddFirst((ElementType)p);
- facet->SetSelected(ev, kODTrue);
- somSelf->CreateProxySelectionBorder(ev, p);
- }
-
- somSelf->ClipEmbeddedFrames(ev, container->GetFrame(ev));
- somSelf->InvalidateSelection(ev, container->GetFrame(ev));
- }
- break;
-
- default:
- // !!! handle multiple selection
- break;
- }
-
- somSelf->InvalidateSelection(ev, container->GetFrame(ev));
- //return somSelf->HandleMouseDownDrag(ev, container, p, event);
-
- _fSession->GetDispatcher(ev)->InvalidateFacetUnderMouse(ev);
- return result;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerHandleKeyDown(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* focusFrame,
- ODEventData* event)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HandleKeyDown");
-
- SOM_TRY
-
- ODUnused(focusFrame);
- ODUnused(event);
- // cursor keys? !!!
-
- return kODFalse;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerHandleMenuEvent(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* focusFrame,
- ODEventData* event)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HandleMenuEvent");
-
- SOM_TRY
-
- ASSERTM(_fMenuBar != kODNULL, 0, "Menubar is NULL");
-
- long menuResult = event->message;
- short menu = HiWord(menuResult);
- short item = LoWord(menuResult);
- ODCommandID command = _fMenuBar->GetCommand(ev, menu, item);
- ODBoolean handled = kODFalse;
-
- // Until such time as we clean this up and register all commands:
- if (!_fMenuBar->IsCommandSynthetic(ev, command))
- {
- switch (command)
- {
- case kODCommandAbout:
- {
- ODArbitrator* fArbitrator = _fSession->GetArbitrator(ev);
- ODWindowState* fWindowState = _fSession->GetWindowState(ev);
- ODTypeToken fModalFocus = _fSession->Tokenize(ev, kODModalFocus);
- TempODFrame currentOwner = fArbitrator->AcquireFocusOwner(ev, fModalFocus);
- if (fArbitrator->RequestFocus(ev, fModalFocus,focusFrame))
- {
- short itemHit;
- SetCursor(&ODQDGlobals.arrow);
- ModalFilterUPP modalFilter = NewModalFilterProc(AboutDialogFilter);
-
- ODSLong savedRefNum;
- BeginUsingLibraryResources(savedRefNum);
- DialogPtr aboutDialog = GetNewDialog(128 ,0,(WindowPtr)-1L);
- EndUsingLibraryResources(savedRefNum);
-
- if (aboutDialog)
- {
- fWindowState->DeactivateFrontWindows(ev);
- ShowWindow(aboutDialog);
- ModalDialog(modalFilter, &itemHit);
- DisposeDialog(aboutDialog);
- fWindowState->ActivateFrontWindows(ev);
- }
- DisposeRoutineDescriptor(modalFilter);
-
- fArbitrator->TransferFocus(ev, fModalFocus,focusFrame, currentOwner);
- handled = kODTrue;
- }
- else
- SysBeep(2);
- }
- break;
- case kODCommandPageSetup:
- if (focusFrame->IsRoot(ev))
- handled = somSelf->HandlePageSetup(ev, focusFrame);
- break;
- case kODCommandPrint:
- if (focusFrame->IsRoot(ev))
- handled = somSelf->HandlePrinting(ev, focusFrame);
- break;
-
- case kODCommandCut:
- handled = somSelf->DoCut(ev, focusFrame); break;
- case kODCommandCopy:
- handled = somSelf->DoCopy(ev, focusFrame); break;
- case kODCommandPaste:
- handled = somSelf->DoPaste(ev, focusFrame); break;
- case kODCommandPasteAs:
- handled = somSelf->DoPasteLink(ev, focusFrame); break;
- case kODCommandClear:
- handled = somSelf->DoClear(ev, focusFrame); break;
- case kODCommandSelectAll:
- handled = somSelf->DoSelectAll(ev, focusFrame); break;
-
- case cGray:
- case cRed:
- case cGreen:
- case cYellow:
- case cBlue:
- case cMagenta:
- case cCyan:
- case cWhite:
- #ifdef BETASEEDMODS
- case cOtherColor:
- #endif
- { //!!! This whole method do with some cleanup
- // Change SetBGColor to use a command number
- short menu;
- short item;
- _fMenuBar->GetMenuAndItem(ev, command, &menu, &item);
- somSelf->SetBGColor1(ev, focusFrame, item-1);
- handled = kODTrue;
- }
- break;
- #ifndef BETASEEDMODS
- case cOtherColor:
- _fPaletteUp = kODTrue;
- somSelf->ShowPalette(ev);
- handled = kODTrue;
- break;
- #endif
-
- #ifdef SCRIPTDEBUG
- case cToggleScripting :
- _fScriptingOn = !_fScriptingOn;
- somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
- handled = kODTrue;
- break;
- #endif
- case kODCommandOpen :
- {
- Proxy* p;
- OrderedCollectionIterator i(_fSelection);
- for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
- {
- ODFrame* frame = p->frame;
- TempODPart part = frame ? frame->AcquirePart(ev) : kODNULL;
- if (part)
- {
- part->Open(ev, frame);
- break;
- }
- }
- }
- handled = kODTrue;
- break;
-
- case kODCommandViewAsWin :
- somSelf->Open(ev, focusFrame);
- handled = kODTrue;
- break;
-
- case kODCommandGetPartInfo :
- {
- Proxy* p;
- OrderedCollectionIterator i(_fSelection);
- p = (Proxy*) i.First();
-
- ODFrame* theFrame = p==kODNULL?focusFrame:p->frame;
- TempODFrameFacetIterator facets(ev,theFrame);
- ODInfo* info = _fSession->GetInfo(ev);
- ODDraftPermissions perms = somSelf->GetStorageUnit(ev)->
- GetDraft(ev)->
- GetPermissions(ev);
- info->ShowPartFrameInfo( ev,
- facets.Current(),
- HAS_WRITE_ACCESS(perms));
- #if ODDebug
- theFrame->Invalidate(ev, (ODShape*)kODNULL, kODNULL);
- #endif
- handled = kODTrue;
- }
- break;
- #if TESTING_DIALOG_TSMTE
- case kODBringUpTestTSMTEDialog:
- BringUpTSMTETestDialog(ev, somSelf, focusFrame);
- handled = kODTrue;
- break;
- #endif
- #ifndef NUKE_PARTSBIN_FOR_DR
- case kODCommandShowPartsBin:
- somSelf->DoShowPartsBin(ev, focusFrame);
- handled = kODTrue;
- break;
- #endif
- case kODCommandPreferences:
- SysBeep(10); SysBeep(10);
- break;
-
- default:
- break;
- }
-
- }
- else
- {
- short menu;
- short item;
- _fMenuBar->GetMenuAndItem(ev, command, &menu, &item);
-
- if (menu == kDrawColorMenuID)
- {
- if (item == kNumColors) {
- _fPaletteUp = kODTrue;
- somSelf->ShowPalette(ev);
- handled = kODTrue;
- }
- else {
- somSelf->SetBGColor1(ev, focusFrame, item-1);
- focusFrame->Invalidate(ev, kODNULL, kODNULL);
- handled = kODTrue;
- }
- }
- else if (menu == kDrawEmbedMenuID)
- {
- switch (_fSelection->Count())
- {
- case 0:
- break;
-
- case 1:
- somSelf->InvalidateSelection(ev, focusFrame);
- somSelf->EmptySelection(ev);
- somSelf->ClipEmbeddedFrames(ev, focusFrame);
- break;
-
- default:
- // !!! handle multiple selection
- break;
- }
- ODPart* newPart;
- somSelf->Embed(ev, item, focusFrame, &newPart);
- handled = kODTrue;
- }
- #ifndef BETASEEDMODS
- else if (menu == kDrawFrameMenuID)
- {
- if (item == 1)
- {
- Proxy* p;
- OrderedCollectionIterator i(_fSelection);
- for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
- {
- p->frame->SetFrozen(ev, true);
- }
- }
- else if (item == 2)
- {
- Proxy* p;
- OrderedCollectionIterator i(_fSelection);
- for (p = (Proxy*) i.First(); i.IsNotComplete(); p = (Proxy*) i.Next())
- {
- p->frame->SetFrozen(ev, false);
- }
- }
- handled = kODTrue;
- }
- #endif
- }
-
- // SetPort(curPort);
- HiliteMenu(0);
- return handled;
-
- SOM_CATCH_ALL
- SOM_ENDTRY
- return kODFalse;
- }
-
- #ifndef _STORUTIL_
- #include <StorUtil.h>
- #endif
-
- #pragma segment DrawPartPrinting
-
- SOM_Scope void SOMLINK AppleTest_ContainerDoShowPartsBin(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DoShowPartsBin");
-
- SOM_TRY
-
- // partsbin code stolen from clock.cpp
-
- #ifndef NUKE_PARTSBIN_FOR_DR
- if ( _fPartsBinOpen )
- {
- if ( _fPartsBinWin != 0 )
- {
- TempODWindow pbWin = _fSession->GetWindowState(ev)->AcquireWindow(ev, _fPartsBinWin);
- // ASSERTM(pbWin != kODNULL, kODErrCannotAcquireWindow, "Cannot Hide Parts Bin");
-
- pbWin->Hide(ev);
- _fPartsBinOpen = kODFalse;
- }
- }
- else
- {
- ODPart* partsbin = kODNULL;
- ODStorageUnit* su = somSelf->GetStorageUnit(ev);
-
- if (!su->Exists(ev, kODPropPartsBin,kODStrongStorageUnitRef,0))
- {
- partsbin = su->GetDraft(ev)->CreatePart(ev, kODKindPartsBin, kODNULL);
- ASSERTM(partsbin != kODNULL, kODErrCannotCreatePart, "Cannot Create Parts Bin");
-
- ODSetStrongSURefProp(ev, su, kODPropPartsBin, kODStrongStorageUnitRef, partsbin->GetStorageUnit(ev)->GetID(ev));
- }
- else
- {
- partsbin = su->GetDraft(ev)->AcquirePart(ev,
- ODGetStrongSURefProp(ev, su, kODPropPartsBin,kODStrongStorageUnitRef));
- }
-
- _fPartsBinWin = partsbin->Open(ev, kODNULL);
- _fPartsBinOpen = kODTrue;
- ODReleaseObject(ev, partsbin);
- }
- #endif
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerStartDrawingLines(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","StartDrawingLines");
-
- if (_fSession->GetArbitrator(ev)->RequestFocus(ev, _fSession->Tokenize(ev, kODMouseFocus), frame))
- {
- _fDrawingLines = kODTrue;
- }
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerStopDrawingLines(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","StopDrawingLines");
-
- if (_fDrawingLines)
- {
- SysBeep(2);
- _fDrawingLines = kODFalse;
- _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fSession->Tokenize(ev, kODMouseFocus),frame);
- }
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerHandlePageSetup(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* focusFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HandlePageSetup");
-
- SOM_TRY
-
- ODUnused(focusFrame);
- PrOpen();
- ASSERTM(PrError() == noErr, PrError(), "DrawPart could not open the PageSetup dialog");
-
- if (!_fPrintRecord)
- {
- somSelf->CreateDefPrintRec(ev);
- }
-
- if (PrStlDialog(_fPrintRecord))
- {
- // • externalize contents to part su
- ODSUForceFocus(ev, _fTestDrawSU, kODPropPrintingInfo,kTPrintRec);
-
- ODULong oldsize = _fTestDrawSU->GetSize(ev);
- ODULong newsize = GetHandleSize((Handle)_fPrintRecord);
-
- HLock((Handle)_fPrintRecord);
- _fTestDrawSU->SetOffset(ev, 0);
- StorageUnitSetValue(_fTestDrawSU, ev, newsize,(ODPtr)(*_fPrintRecord));
-
- if (oldsize > newsize)
- _fTestDrawSU->DeleteValue(ev, oldsize-newsize);
- }
-
- PrClose();
-
- return kODTrue;
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerHandlePrinting(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* focusFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HandlePrinting");
-
- SOM_TRY
-
- PrOpen();
- ASSERTM(PrError() == noErr, PrError(), "DrawPart could not open the PageSetup dialog");
-
- if (!_fPrintRecord)
- {
- somSelf->CreateDefPrintRec(ev);
- }
-
- if (PrJobDialog(_fPrintRecord))
- {
- somSelf->PrintDocument(ev, focusFrame);
- }
-
- PrClose();
-
- return kODTrue;
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerCreateDefPrintRec(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","CreateDefPrintRec");
-
- SOM_TRY
-
- _fPrintRecord = (THPrint) ODNewHandle(sizeof(TPrint));
- if (!_fPrintRecord)
- {
- THROW(kODErrOutOfMemory);
- }
-
- PrintDefault(_fPrintRecord);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
-
- SOM_Scope ODFacet* SOMLINK AppleTest_ContainerBeginPrinting(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* rootFrame,
- TPrPort* thePrPort)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","BeginPrinting");
-
- SOM_TRY
-
- TempODTransform xtransform = rootFrame->CreateTransform(ev);
-
- Rect pagerect = (**_fPrintRecord).prInfo.rPage;
-
- TempODShape clipshape = rootFrame->CreateShape(ev);
- ODRect cliprect(pagerect);
- clipshape->SetRectangle(ev, &cliprect);
-
- ODFacet* prFacet = _fSession->GetWindowState(ev)->
- CreateFacet(ev, rootFrame, clipshape, xtransform, kODNULL, kODNULL);
-
- ODCanvas* prCanvas = prFacet->CreateCanvas(ev, kODQuickDraw,
- (ODPlatformCanvas)thePrPort, kODFalse, kODFalse);
- prCanvas->SetPlatformPrintJob(ev, kODQuickDraw, (ODPlatformCanvas)_fPrintRecord);
- prCanvas->SetOwner(ev, _fPartWrapper);
- prFacet->ChangeCanvas(ev, prCanvas);
-
- rootFrame->FacetAdded(ev, prFacet);
-
- return prFacet;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerPrintPage(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* prFacet,
- ODUShort page)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","PrintPage");
-
- SOM_TRY
-
- Rect pageSize = (**_fPrintRecord).prInfo.rPage;
- ODRect bbox;
- Rect frect;
-
- TempODShape frameShape = prFacet->GetFrame(ev)->AcquireFrameShape(ev, kODNULL);
- frameShape->GetBoundingBox(ev, &bbox);
- bbox.AsQDRect(frect);
-
- ODULong height = frect.bottom;
- ODULong width = frect.right;
-
- Point pt = {0,0};
- ODUShort locator = page-1;
-
- while (locator)
- {
- pt.v += (pageSize.bottom+1);
- locator--;
-
- if (PtInRect(pt,&frect))
- {
- continue;
- }
- else
- {
- pt.v = 0;
- pt.h += (pageSize.right+1);
- }
- }
-
- TempODTransform xtransform = prFacet->CreateTransform(ev);
-
- xtransform->SetQDOffset(ev, &pt);
-
- Rect pagerect = (**_fPrintRecord).prInfo.rPage;
-
- TempODShape clipshape = prFacet->CreateShape(ev);
- ODRect cliprect(pagerect);
- clipshape->SetRectangle(ev, &cliprect);
- TempODShape invalshape = clipshape->Copy(ev); // DMc refcount - make temp
- clipshape->Transform(ev, xtransform);
- //clipshape->GetBoundingBox(&bbox); // !!!
- xtransform->Invert(ev);
- prFacet->ChangeGeometry(ev, clipshape, xtransform, kODNULL);
-
- prFacet->Update(ev, invalshape, kODNULL); // DMc refcount - use temp
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerEndPrinting(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* prFacet)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","EndPrinting");
-
- SOM_TRY
-
- ODCanvas* prCanvas = prFacet->GetCanvas(ev);
-
- prFacet->GetFrame(ev)->FacetRemoved(ev, prFacet);
-
- delete prCanvas;
- delete prFacet;
-
- SOM_CATCH_ALL_ENDTRY
- }
-
-
- ODUShort DetermineNumberOfPagesinDoc(Environment* ev, ODFrame* frame, Rect page)
- {
- ODRect bbox;
- Rect frect;
-
- TempODShape frameShape = frame->AcquireFrameShape(ev, kODNULL);
- frameShape->GetBoundingBox(ev, &bbox);
- bbox.AsQDRect(frect);
-
- ODSLong height = frect.bottom;
- ODSLong width = frect.right;
-
- ODUShort pages = 0;
-
- ODSLong wt = width;
- while (wt > 0)
- {
- ODSLong ht = height;
- while (ht > 0)
- {
- ht -= page.bottom;
- pages++;
- }
-
- wt -= page.right;
- }
-
- return pages;
- }
-
-
- SOM_Scope void SOMLINK AppleTest_ContainerPrintDocument(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","PrintDocument");
-
- SOM_TRY
-
- GrafPtr oldPort;
- ODUShort copies,
- firstPage,
- lastPage,
- numberOfCopies,
- printmgrsResFile,
- realNumberOfPagesinDoc,
- pageNumber,
- PrintError;
- // THPrint thePrRecHdl;
- TPPrPort thePrPort;
- TPrStatus theStatus;
- ODFacet* prFacet;
-
- GetPort(&oldPort);
-
- PrOpen();
-
- if (PrError() == noErr)
- {
- /**
- Save the current resource file (i.e. the printer driver's) so
- the driver will not lose its resources upon return from the pIdleProc.
- **/
- printmgrsResFile = CurResFile();
-
- realNumberOfPagesinDoc = DetermineNumberOfPagesinDoc(ev, frame,(**_fPrintRecord).prInfo.rPage);
-
- numberOfCopies = (**_fPrintRecord).prJob.iCopies;
-
- firstPage = (**_fPrintRecord).prJob.iFstPage;
- lastPage = (**_fPrintRecord).prJob.iLstPage;
-
- (**_fPrintRecord).prJob.iFstPage = 1;
- (**_fPrintRecord).prJob.iLstPage = 9999;
-
- if (realNumberOfPagesinDoc < lastPage)
- lastPage = realNumberOfPagesinDoc;
-
- //PrintingStatusDialog = GetNewDialog(257, nil, (WindowPtr) -1);
-
- for (copies = 1; copies <= numberOfCopies; copies++)
- {
- // Install a pointer to your pIdle proc in my print record.
- //(**thePrRecHdl).prJob.pIdleProc = checkMyPrintDialogButton;
-
- UseResFile(printmgrsResFile);
- thePrPort = PrOpenDoc(_fPrintRecord, nil, nil);
-
- if (PrError() == noErr)
- {
- TRY
- prFacet = somSelf->BeginPrinting(ev, frame, thePrPort);
- THROW_IF_NULL(prFacet);
-
- pageNumber = firstPage;
- while (pageNumber <= lastPage && PrError() == noErr)
- {
- PrOpenPage(thePrPort, nil);
-
- if (PrError() == noErr)
- {
- somSelf->PrintPage(ev, prFacet, pageNumber);
- }
-
- PrClosePage(thePrPort);
- pageNumber++;
- }
-
- somSelf->EndPrinting(ev, prFacet);
- CATCH_ALL
- // garbage collection needs to be improved
- ENDTRY
-
- }
-
- PrCloseDoc(thePrPort);
- }
- }
-
- if (((**_fPrintRecord).prJob.bJDocLoop == bSpoolLoop) && (PrError() == noErr))
- PrPicFile(_fPrintRecord, nil, nil, nil, &theStatus);
-
- PrintError = PrError();
-
- PrClose();
-
- THROW_IF_ERROR(PrintError);
-
- //if (PrintingStatusDialog != nil)
- // DisposDialog(PrintingStatusDialog);
-
- SetPort(oldPort);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerDoCut(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DoCut");
-
- SOM_TRY
-
- ODUnused(frame);
- return kODFalse;
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerDoCopy(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DoCopy");
-
- SOM_TRY
-
- ODUnused(frame);
- return kODFalse;
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerDoPaste(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DoPaste");
-
- SOM_TRY
-
- ODUnused(frame);
- return kODFalse;
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerDoPasteLink(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DoPasteLink");
-
- SOM_TRY
-
- ODUnused(frame);
- return kODFalse;
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerDoClear(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DoClear");
-
- SOM_TRY
-
- OrderedCollectionIterator i(_fSelection);
- Proxy* selection = (Proxy*)i.First();
-
- if ( selection )
- {
- frame->Invalidate(ev, kODNULL, kODNULL);
- somSelf->EmptySelection(ev);
-
- OrderedCollection* tempFacets = new OrderedCollection;
-
- // Get all facets displaying the moved frame
- // Necessary because they can't be deleted during iteration
- // We can't use the frame's facet iterator because the destination
- // of the move will have changed the frame's containing frame,
- // which eliminates all facets.
- ODFrameFacetIterator* facets = selection->frame->CreateFacetIterator(ev);
- for (ODFacet* f1 = facets->First(ev);
- facets->IsNotComplete(ev);
- f1 = facets->Next(ev))
- {
- tempFacets->AddLast(f1);
- }
- delete facets;
-
- // Now delete all facets displaying the moved frame
- OrderedCollectionIterator t(tempFacets);
- for (ODFacet* f2 = (ODFacet*)t.First();
- t.IsNotComplete();
- f2 = (ODFacet*)t.Next())
- {
- f2->GetContainingFacet(ev)->RemoveFacet(ev, f2);
- ODDeleteObject(f2);
- }
- delete tempFacets;
-
- ODFrame* movedFrame = selection->frame;
-
- movedFrame->Acquire(ev); // So that when we Remove/Release it below, we are using a valid pointer
-
- // Remove our proxy for the moved frame
- somSelf->DeleteFrameProxy(ev, selection); // NOTE: this implicitly releases movedFrame!
-
- // movedFrame->SetContainingFrame(ev, kODNULL);
- movedFrame->Remove(ev);
- movedFrame = kODNULL;
-
- // Reset clipping of the remaining embedded facets
- somSelf->ClipEmbeddedFrames(ev, frame);
-
- somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
- return kODTrue;
- }
- else
- {
- return kODFalse;
- }
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerDoSelectAll(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DoSelectAll");
-
- SOM_TRY
-
- ODUnused(frame);
- return kODFalse;
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerActivateFrame(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ActivateFrame");
-
- SOM_TRY
-
- if (frame != (_fPalette ? _fPalette->GetRootFrame(ev) : kODNULL))
- {
- PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
- WASSERTM(pInfo != kODNULL, "partInfo on activating frame is NULL");
- if (!(pInfo->fIsActive))
- {
- ODBoolean succeeded = false;
-
- succeeded = _fSession->GetArbitrator(ev)->RequestFocusSet(ev, _fFocusSet,frame);
-
- if (succeeded)
- {
- somSelf->FocusAcquired(ev, _fSelectionFocus, frame);
- somSelf->FocusAcquired(ev, _fMenuFocus, frame);
- somSelf->FocusAcquired(ev, _fKeyFocus, frame);
- }
- }
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerDeActivateFrame(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DeActivateFrame");
-
- SOM_TRY
-
- if (frame != (_fPalette ? _fPalette->GetRootFrame(ev) : kODNULL)) {
- ODArbitrator* arbitrator = _fSession->GetArbitrator(ev);
-
- arbitrator->RelinquishFocusSet(ev, _fFocusSet,frame);
- somSelf->FocusLost(ev, _fSelectionFocus, frame);
- somSelf->FocusLost(ev, _fMenuFocus, frame);
- somSelf->FocusLost(ev, _fKeyFocus, frame);
-
- TempODFrame clipboardFocus = arbitrator->AcquireFocusOwner(ev, _fClipboardFocus);
- if ( frame == clipboardFocus )
- {
- arbitrator->RelinquishFocus(ev, _fClipboardFocus, frame);
- somSelf->FocusLost(ev, _fClipboardFocus, frame);
- }
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerActivatingWindow(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ActivatingWindow");
-
- SOM_TRY
-
- #if ODDebug
- // somPrintf("DrawPart Activate Event for frame %x\n", frame);
- #endif
-
- PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
- TempODFrame activeFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fSelectionFocus);
- if ((pInfo->fNeedsActivating)) // && (activeFrame == kODNULL))
- {
- #if ODDebug
- // somPrintf("DrawPart: Need to activate frame %x\n", frame);
- #endif
- somSelf->ActivateFrame(ev, frame);
- somSelf->ShowPalette(ev);
- pInfo->fNeedsActivating = kODFalse;
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerDeActivatingWindow(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DeActivatingWindow");
-
- SOM_TRY
-
- #if ODDebug
- // somPrintf("DrawPart Deactivate Event for frame %x\n", frame);
- #endif
-
- PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
- TempODFrame activeFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fSelectionFocus);
- if (frame == activeFrame)
- {
- #if ODDebug
- // somPrintf("DrawPart: Will Need to activate frame %x\n", frame);
- #endif
- pInfo->fNeedsActivating = kODTrue;
- //somSelf->DeActivateFrame(ev, frame);
- }
- else
- {
- #if ODDebug
- // somPrintf("DrawPart: Won't Need to activate frame %x\n", frame);
- #endif
- pInfo->fNeedsActivating = kODFalse;
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerInstallMenus(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* aFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","InstallMenus");
-
- SOM_TRY
-
- if (aFrame && _fMenuBar)
- _fMenuBar->Display(ev);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerRemoveMenus(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* aFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","RemoveMenus");
-
- SOM_TRY
-
- ODUnused(aFrame);
-
- // Don't need to remove the menus we've added
- // Just disable Shell menu items we've enabled
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerSetBGColor1(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* aFrame,
- ODUShort whichColor)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","SetBGColor1");
-
- SOM_TRY
-
- PartInfoRec* pInfo = (PartInfoRec *) aFrame->GetPartInfo(ev);
- if (!pInfo)
- { pInfo = new PartInfoRec;
- aFrame->SetPartInfo(ev, (ODInfoType) pInfo);
- };
-
- RGBColor newColor = pInfo->bgColor;
-
- switch (whichColor)
- {
- case kGray: newColor = rgbGray; break;
- case kRed: newColor = rgbRed; break;
- case kGreen: newColor = rgbGreen; break;
- case kYellow: newColor = rgbYellow; break;
- case kBlue: newColor = rgbBlue; break;
- case kMagenta: newColor = rgbMagenta; break;
- case kCyan: newColor = rgbCyan; break;
- case kWhite: newColor = rgbWhite; break;
- case kOther:
- {
- Point where = {0, 0};
- ConstStr255Param prompt = {"\pPick a new background color:"};
- RGBColor outColor;
-
- if ( GetColor(where, prompt, &pInfo->bgColor, &outColor) )
- newColor = outColor;
- }
- break;
- default: break;
- }
- somSelf->UserSetBGColor(ev, aFrame,&newColor);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- struct SetBGColorRec
- {
- SetBGColorRec(RGBColor oldColor, RGBColor newColor, ODFrame* frame)
- {_fOldColor = oldColor; _fNewColor = newColor;
- _fFrame = frame;}
- RGBColor _fOldColor;
- RGBColor _fNewColor;
- ODFrame* _fFrame;
- };
-
-
- SOM_Scope void SOMLINK AppleTest_ContainerUserSetBGColor(AppleTest_Container *somSelf,
- Environment *ev,
- ODFrame* frame,
- RGBColor *whichColor)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","UserSetBGColor");
-
- SOM_TRY
-
- PartInfoRec* pInfo = (PartInfoRec *) frame->GetPartInfo(ev);
- if (!pInfo)
- { pInfo = new PartInfoRec;
- frame->SetPartInfo(ev, (ODInfoType) pInfo);
- }
- if (!RGBEqual(*whichColor,pInfo->bgColor))
- {
- ODIText* undoActionName;
- ODIText* redoActionName;
-
- ODScriptCode script = FontToScript( GetSysFont() );
- ODLangCode lang = GetScriptVariable(script, smScriptLang);
-
- undoActionName = CreateIText(script, lang, "\pUndo Set Color");
- redoActionName = CreateIText(script, lang, "\pRedo Set Color");
- SetBGColorRec* undoRec = new SetBGColorRec(pInfo->bgColor, *whichColor,
- frame);
-
- // Cheat here. Only send the pointer. Assumes no one else will try
- // to peak to the undo stack to look at our data.
- ODActionData data = CreateByteArrayStruct(&undoRec,
- sizeof(SetBGColorRec*));
-
- _fSession->GetUndo(ev)->AddActionToHistory(ev, _fPartWrapper, &data,
- kODSingleAction,
- (ODName*)undoActionName,
- (ODName*)redoActionName);
-
- DisposeByteArrayStruct(data);
- DisposeIText(undoActionName);
- DisposeIText(redoActionName);
-
- somSelf->SetBGColor2(ev, frame, whichColor);
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerSetBGColor2(AppleTest_Container *somSelf,
- Environment *ev,
- ODFrame* aFrame,
- RGBColor *whichColor)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","SetBGColor2");
-
- SOM_TRY
-
- PartInfoRec* pInfo = (PartInfoRec *) aFrame->GetPartInfo(ev);
- if (!pInfo)
- { pInfo = new PartInfoRec;
- aFrame->SetPartInfo(ev, (ODInfoType) pInfo);
- }
- if (!RGBEqual(*whichColor,pInfo->bgColor))
- {
- pInfo->bgColor = *whichColor;
- somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
- aFrame->Invalidate(ev, kODNULL, kODNULL);
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerEmbed(AppleTest_Container *somSelf, Environment *ev,
- short item,
- ODFrame* frame,
- ODPart** newPart)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","Embed");
-
- SOM_TRY
-
- if (item != 1)
- return;
-
- ODWindowState* windowState = _fSession->GetWindowState(ev);
- ODStorageUnit* su = somSelf->GetStorageUnit(ev);
- ODType partkind = kODNULL;
-
- // StdGetFile please select an editor for the root part
- StandardFileReply sfReply;
- SFTypeList sfTypes;
- sfTypes[0] = 'shlb';
- sfTypes[1] = 'shlb';
- sfTypes[2] = 'shlb';
- sfTypes[3] = 'shlb';
-
- windowState->DeactivateFrontWindows(ev);
- StandardGetFile((FileFilterUPP)kODNULL,1,sfTypes,&sfReply);
- windowState->ActivateFrontWindows(ev);
-
- if (sfReply.sfGood)
- {
- ODPart* embeddedPart;
-
- ODSShort saveResFile = CurResFile();
- ODSShort resRefNum = FSpOpenResFile(&(sfReply.sfFile),fsRdPerm);
- EditorSet* theEditorSet = ODGetEditorSetFromResFile(resRefNum);
- CloseResFile(resRefNum);
- UseResFile(saveResFile);
- if (theEditorSet)
- {
- EditorSetIterator* itr = theEditorSet->CreateIterator();
- ODEditor editor = itr->First();
- ODDeleteObject( itr );
- ODDeleteObject( theEditorSet );
-
- embeddedPart = su->GetDraft(ev)->CreatePart(ev, kODNULL, editor);
- embeddedPart->Externalize(ev);
-
- TempODTransform externalXForm = frame->CreateTransform(ev);
- ODSLong count = 1 + _fContents->Count();
-
- Point ptTemp;
- SetPt(&ptTemp,(short)(count*20),(short)(count*20));
- externalXForm->SetQDOffset(ev, &ptTemp);
- TempODFrame embeddedFrame = somSelf->MakeEmbeddedFrame(ev, frame,
- kODNULL,
- externalXForm,
- embeddedPart,
- kODFalse);
-
- ODFrameFacetIterator* facets = frame->CreateFacetIterator(ev);
- for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev);
- facet = facets->Next(ev))
- {
- TempODShape frameShape = embeddedFrame->AcquireFrameShape(ev, kODNULL);
- TempODShape clip = frameShape->Copy(ev);
- TempODTransform xform = somSelf->ProxyForFrame(ev, embeddedFrame)->transform->Copy(ev);
- facet->CreateEmbeddedFacet(ev, embeddedFrame, clip, xform,
- kODNULL, kODNULL, kODNULL, kODFrameInFront);
- }
- delete facets;
- somSelf->ClipEmbeddedFrames(ev, frame);
- frame->Invalidate(ev, kODNULL, kODNULL);
-
- if (newPart)
- *newPart = embeddedPart;
- else
- ODReleaseObject(ev,embeddedPart);
- }
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
-
-
-
-
- SOM_Scope void SOMLINK AppleTest_ContainerSetGrafPortOrigin(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* facet)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","SetGrafPortOrigin");
-
- SOM_TRY
-
- TempODTransform localToGlobal = facet->AcquireContentTransform(ev, kODNULL);
- ODPoint offset(0,0);
- localToGlobal->TransformPoint(ev, &offset);
- SetOrigin(-offset.IntX(), -offset.IntY());
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerInvalEmbedFrameAfterResize(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* facet,
- Proxy* selection,
- ODShape* oldShape,
- ODShape* newShape,
- Point* transOffset)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","InvalEmbedFrameAfterResize");
-
- SOM_TRY
-
- // invalidate old frame shape
- TempODShape oldShapeCopy = oldShape->Copy(ev);
- oldShapeCopy->Transform(ev, selection->transform);
- facet->GetFrame(ev)->Invalidate(ev, oldShapeCopy, kODNULL);
-
- TempODShape newShapeCopy = newShape->Copy(ev); // save to invalidate later
-
- selection->frame->ChangeFrameShape(ev, newShape, kODNULL); // already in frame coords
-
- // if the left or top side of the frame was adjusted, the transform will be updated
- if ((transOffset->h != 0) || (transOffset->v != 0))
- {
- ODPoint ODtransOffset (*transOffset);
- selection->transform->MoveBy(ev, &ODtransOffset);
-
- // $$$$$ move facets for selected frame - this is slightly hackish
- ODFacetIterator* facets =
- facet->GetWindow(ev)->GetRootFacet(ev)->CreateFacetIterator(ev, kODTopDown, kODFrontToBack);
- for (ODFacet* child = facets->First(ev);
- facets->IsNotComplete(ev); child = facets->Next(ev))
- {
- if (child->GetFrame(ev) == selection->frame)
- {
- TempODTransform newTrans = selection->transform->Copy(ev);
- child->ChangeGeometry(ev, kODNULL, newTrans, kODNULL);
- facets->SkipChildren(ev);
- }
- }
- delete facets;
- }
-
- // invalidate changed areas
- newShapeCopy->Transform(ev, selection->transform);
- facet->GetFrame(ev)->Invalidate(ev, newShapeCopy, kODNULL);
-
- somSelf->InvalidateSelection(ev, facet->GetFrame(ev));
- somSelf->UpdateProxyRegion(ev, selection);
- somSelf->CreateProxySelectionBorder(ev, selection);
- somSelf->ClipEmbeddedFrames(ev, facet->GetFrame(ev));
- somSelf->InvalidateSelection(ev, facet->GetFrame(ev));
-
- // DMc: Changing presentation is an "incidental" state change that should not
- // force the document to becoe dirty; do not call SetChangedFromPrev().
- // somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
-
- SOM_Scope Rect* SOMLINK AppleTest_ContainerGetSelectionRectLocal(AppleTest_Container *somSelf, Environment *ev,
- Proxy* selection)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","GetSelectionRectLocal");
-
- SOM_TRY
-
- TempODShape frameShape = selection->frame->AcquireFrameShape(ev, kODNULL);
- RgnHandle shapeRgn = frameShape->GetQDRegion(ev);
- Rect shapeRect = (**shapeRgn).rgnBBox;
-
- Rect* localRect = new Rect;
- SetRect(localRect, shapeRect.left, shapeRect.top,
- shapeRect.right, shapeRect.bottom);
-
- Point offset = selection->transform->GetQDOffset(ev);
- OffsetRect(localRect, offset.h, offset.v);
-
- return localRect;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerCreatePalette(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","CreatePalette");
-
- SOM_TRY
-
- if (_fPalette == kODNULL) {
- ODPlatformWindow platformWindow;
- Rect windRect;
-
- SetRect(&windRect, kPaletteLeft, kPaletteTop, kPaletteRight, kPaletteBottom);
- platformWindow = NewCWindow(kODNULL,
- &windRect,
- "\p",
- false,
- noGrowDocProc,
- (WindowPtr)-1L,
- true,
- kODNULL);
- MoveWindow(platformWindow, 100, 100, kODFalse);
- _fPalette = somSelf->GetStorageUnit(ev)->GetSession(ev)->GetWindowState(ev)->
- RegisterWindow(ev, platformWindow,
- kODFrameObject,
- kODFalse,
- kODFalse, // Is resizable
- kODTrue, // Is floating
- kODFalse, // don't save
- kODTrue, // should dispose
- _fPartWrapper,
- _fSession->Tokenize(ev, kODViewAsFrame),
- _fSession->Tokenize(ev, kDrawPresPalette),
- kODNULL);
- _fPalette->Open(ev);
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerDestroyPalette(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DestroyPalette");
-
- SOM_TRY
-
- if (_fPalette != kODNULL) {
- _fPalette->CloseAndRemove(ev);
- _fPalette = kODNULL;
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerShowPalette(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ShowPalette");
-
- SOM_TRY
-
- if (_fPaletteUp != kODFalse) {
- if (_fPalette == kODNULL)
- somSelf->CreatePalette(ev);
- _fPalette->Show(ev);
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerHidePalette(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HidePalette");
-
- SOM_TRY
-
- if (_fPalette != kODNULL) {
- _fPalette->Hide(ev);
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerGetBGColor(AppleTest_Container *somSelf, Environment *ev,
- ODUShort whichColor,
- RGBColor* newColor)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","GetBGColor");
-
- SOM_TRY
-
- switch (whichColor)
- {
- case kGray: *newColor = rgbGray; break;
- case kRed: *newColor = rgbRed; break;
- case kGreen: *newColor = rgbGreen; break;
- case kYellow: *newColor = rgbYellow; break;
- case kBlue: *newColor = rgbBlue; break;
- case kMagenta: *newColor = rgbMagenta; break;
- case kCyan: *newColor = rgbCyan; break;
- case kWhite: *newColor = rgbWhite; break;
-
- default:
- WASSERTM(kODFalse, "No such color.");
- break;
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
-
- SOM_Scope ODFrame* SOMLINK AppleTest_ContainerMakeEmbeddedFrame(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* containingFrame,
- ODShape* frameShape,
- ODTransform* externalTransform,
- ODPart* embedPart,
- ODBoolean isOverlaid)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","MakeEmbeddedFrame");
-
- SOM_TRY
-
- TempODShape newShape = NULL;
-
- // decide what newShape should be - for now, give it what it asked for
- if (frameShape)
- {
- newShape = frameShape;
- newShape ->Acquire(ev);
- }
- else
- { // no frameShape specified, use a default size
- ODRect rect;
- rect.SetInt(0,0,80,80);
- newShape = containingFrame->CreateShape(ev);
- newShape->SetRectangle(ev, &rect);
- }
-
- // create the new frame
- // kODNullTypeToken
- ODFrame* newFrame = somSelf->GetStorageUnit(ev)->GetDraft(ev)->
- CreateFrame(ev, kODFrameObject, containingFrame, newShape, (ODCanvas*)kODNULL,
- embedPart, _fSession->Tokenize(ev, kODViewAsFrame), _fSession->Tokenize(ev, kODPresDefault),
- kODFalse, isOverlaid);
-
- somSelf->CreateFrameProxy(ev, newFrame, externalTransform);
-
- return newFrame;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- SOM_Scope ODWindow* SOMLINK AppleTest_ContainerCreateWindow(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* sourceFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","CreateWindow");
-
- SOM_TRY
-
- Rect windRect;
- ODPlatformWindow platformWindow = kODNULL;
- ODWindow* window = kODNULL;
-
- if (sourceFrame)
- {
- SetRect(&windRect, 100, 100, 300, 300);
- }
- else
- {
- const ODSShort kOnePageWidth = 600;
- // Get the menu bar height, for figuring the top of our windows
- ODSShort mbHeight = 24; //(*(ODSShort*)MBarHeight); //get it from lomem
- SetRect(&windRect, 4, mbHeight+16,
- ODQDGlobals.screenBits.bounds.right - 64,
- ODQDGlobals.screenBits.bounds.bottom - 4);
-
- if (windRect.right-windRect.left > kOnePageWidth)
- {
- windRect.right = windRect.left + kOnePageWidth;
- }
- }
-
- ODName* windowName = kODNULL;
- Str255 pWindowName;
- if (sourceFrame)
- windowName = ODGetPartName(ev, sourceFrame, kODNULL);
- if (windowName==kODNULL || GetITextStringLength(windowName)==0)
- CopyPascalString(pWindowName, "\pContainer");
- else
- GetITextPString(windowName, pWindowName);
-
- if (windowName)
- DisposeIText(windowName);
-
- platformWindow = NewCWindow(kODNULL, &windRect, pWindowName, false, zoomDocProc, (WindowPtr)-1L, true, kODNULL);
- window = _fSession->GetWindowState(ev)->RegisterWindow(ev, platformWindow,
- kODFrameObject,
- (sourceFrame==kODNULL), // Keeps draft open
- kODTrue, // Is resizable
- kODFalse, // Is floating
- kODTrue, // should save
- kODTrue, // should dispose
- _fPartWrapper,
- _fSession->Tokenize(ev, kODViewAsFrame),
- _fSession->Tokenize(ev, kDrawPresNormal),
- sourceFrame);
-
- return window;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainersomInit(AppleTest_Container *somSelf)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("DrawPart","somInit");
-
- parent_somInit(somSelf);
-
- gSession = kODNULL;
-
- _fDisplayFrames = kODNULL;
- _fEmbeddedFrames = kODNULL;
- _fWindowID = 0;
-
- _fFrameGroupIDCounter = 1;
-
- _fContents = kODNULL;
- _fSelection = kODNULL;
-
- _fSelectRgn = kODNULL;
- _fCornerHandleRgn = kODNULL;
- _fEdgeHandleRgn = kODNULL;
-
- _fColorMenu = kODNULL;
- _fEmbedMenu = kODNULL;
- _fFrameMenu = kODNULL;
- _fScriptingMenu = kODNULL;
- _fMenuBar = kODNULL;
- _fFocusSet = kODNULL;
-
- _fSemtIntf = kODNULL;
- _fTestDrawSU = kODNULL;
-
- _fPalette = kODNULL;
- _fPaletteUp = kODFalse;
- _fPaletteWasShown = kODFalse;
- _fScriptingOn = kODTrue;
-
- _fLargeIcons = kODNULL;
- _fSmallIcons = kODNULL;
-
- _fSession = kODNULL;
-
- _fPrintRecord = kODNULL;
- _fPartWrapper = kODNULL;
- _fDrawingLines = kODFalse;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainersomUninit(AppleTest_Container *somSelf)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("DrawPart","somUninit");
-
- if (_fContents != kODNULL)
- delete _fContents;
- if (_fSelection != kODNULL)
- delete _fSelection;
- if (_fSelectRgn) ODDisposeHandle((Handle)_fSelectRgn);
- if (_fCornerHandleRgn) ODDisposeHandle((Handle)_fCornerHandleRgn);
- if (_fEdgeHandleRgn) ODDisposeHandle((Handle)_fEdgeHandleRgn);
-
- Environment* ev = somGetGlobalEnvironment();
-
- if (_fMenuBar != kODNULL) {
- _fMenuBar->UnregisterCommand(ev, cGray);
- _fMenuBar->UnregisterCommand(ev, cRed);
- _fMenuBar->UnregisterCommand(ev, cGreen);
- _fMenuBar->UnregisterCommand(ev, cYellow);
- _fMenuBar->UnregisterCommand(ev, cBlue);
- _fMenuBar->UnregisterCommand(ev, cMagenta);
- _fMenuBar->UnregisterCommand(ev, cCyan);
- _fMenuBar->UnregisterCommand(ev, cWhite);
- _fMenuBar->UnregisterCommand(ev, cOtherColor);
-
- _fMenuBar->RemoveMenu(ev, kDrawColorMenuID);
- _fMenuBar->RemoveMenu(ev, kDrawEmbedMenuID);
- #ifndef BETASEEDMODS
- _fMenuBar->RemoveMenu(ev, kDrawFrameMenuID);
- #endif
-
- #ifdef SCRIPTDEBUG
- _fMenuBar->UnregisterCommand(ev, cToggleScripting);
- _fMenuBar->RemoveMenu(ev, kDrawScriptingMenuID);
- #endif
-
- _fMenuBar->Release(ev);
- }
-
- if (_fFocusSet) delete _fFocusSet;
-
- if (_fColorMenu) DisposeMenu(_fColorMenu);
- if (_fEmbedMenu) DisposeMenu(_fEmbedMenu);
- #ifndef BETASEEDMODS
- if (_fFrameMenu) DisposeMenu(_fFrameMenu);
- #endif
-
- #ifdef SCRIPTDEBUG
- if (_fScriptingMenu) DisposeMenu(_fScriptingMenu);
- #endif
-
- if (_fDisplayFrames != kODNULL)
- delete _fDisplayFrames; // make sure it's empty first
- if (_fEmbeddedFrames != kODNULL)
- delete _fEmbeddedFrames; // make sure it's empty first
-
- ODReleaseObject(ev,_fTestDrawSU);
- parent_somUninit(somSelf);
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerFulfillPromise(AppleTest_Container *somSelf, Environment *ev,
- ODStorageUnitView* promiseSUView)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","FulfillPromise");
-
- SOM_TRY
-
- TempODPropertyName property = promiseSUView->GetProperty(ev);
-
- if ( ODISOStrEqual(property, kPropFrameInfo) ) {
- Proxy* selection = kODNULL;
-
- // Just to test whether GetPromiseValue works
- {
- const ODULong kBufferSize = 255;
- ODPart* part = kODNULL;
- ODByteArray ba;
- ODULong length = promiseSUView->GetPromiseValue(ev, kDrawFrameID, 0, kBufferSize, &ba, &part);
- if ((length != sizeof(ODID)) || (part != _fPartWrapper)) {
- WARN("GetPromiseValue fails!");
- }
- ODDisposePtr(ba._buffer);
- }
-
- ODULong size = promiseSUView->GetSize(ev);
- ASSERTM(size == sizeof(Proxy*), kODErrAssertionFailed, "Invalid Proxy");
- if (size != sizeof(Proxy*)) {
- promiseSUView->DeleteValue(ev, size);
- }
- else {
- StorageUnitViewGetValue(promiseSUView, ev, sizeof(Proxy*), &selection);
- promiseSUView->SetOffset(ev, 0);
- ODID frameInfoData = selection->frame->GetID(ev);
- StorageUnitViewSetValue(promiseSUView, ev, sizeof(ODID), (ODValue) &frameInfoData);
- }
- }
- else if ( ODISOStrEqual(property, kODPropMouseDownOffset) ) {
- // The promise data is also the correct value
- // $$$$$ Is it mandatory that the promise be replaced by SetValue???
- ODULong size = promiseSUView->GetSize(ev);
- ASSERTM(size == sizeof(Point), kODErrAssertionFailed, "Invalid Point");
- Point mdOffset;
- StorageUnitViewGetValue(promiseSUView, ev, sizeof(Point), (ODValue) &mdOffset);
- promiseSUView->SetOffset(ev, 0);
- StorageUnitViewSetValue(promiseSUView, ev, sizeof(Point), (ODValue) &mdOffset);
- }
- else if ( ODISOStrEqual(property, kODPropContents) ) {
-
- #if ODDebug
- somPrintf("Draw %d::FulfillPromise: Fulfilling promised content\n", somSelf->GetID(ev));
- #endif
- // Clone this part's content
- ODStorageUnit* toSU = promiseSUView->GetStorageUnit(ev);
- ODDraft* toDraft = promiseSUView->GetStorageUnit(ev)->GetDraft(ev);
- ODDraft* fromDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
- ODStorageUnit* testDrawContentSU = toDraft->CreateStorageUnit(ev);
- ODDraftKey key = 0;
- ODID toID = 0;
- ODFrame* scopeFrame = kODNULL; // $$$$$ should come from promise value
- TRY
- key = fromDraft->BeginClone(ev, toDraft, kODNULL, kODCloneCut); // $$$$$ is cut vs. copy significant???
- somSelf->CloneTestDrawContent(ev, key, testDrawContentSU, scopeFrame);
- fromDraft->EndClone(ev, key);
- CATCH_ALL
- WARN("Clone Problem in DrawPartFulfillPromise.");
- if (key != 0)
- fromDraft->AbortClone(ev, key);
- RERAISE;
- ENDTRY
-
- // Replace the promise with a reference to the cloned storage unit
- ODStorageUnitRef aSURef;
- promiseSUView->GetStrongStorageUnitRef(ev, testDrawContentSU->GetID(ev), aSURef);
- promiseSUView->SetOffset(ev, 0);
- StorageUnitViewSetValue(promiseSUView, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
- }
-
- #if ODDebug
- somPrintf("Draw %d::FulfillPromise: Complete\n", somSelf->GetID(ev));
- #endif
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerDropCompleted(AppleTest_Container *somSelf, Environment *ev,
- ODPart* destPart,
- ODDropResult dropResult)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DropCompleted");
-
- SOM_TRY
-
- ODUnused(destPart);
- ODUnused(dropResult);
- // parent_DropCompleted(somSelf,ev,destPart,dropResult);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope ODDragResult SOMLINK AppleTest_ContainerDragEnter(AppleTest_Container *somSelf, Environment *ev,
- ODDragItemIterator* dragInfo,
- ODFacet* facet,
- ODPoint* where)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DragEnter");
-
- SOM_TRY
-
- ODUnused(dragInfo);
- ODUnused(where);
-
- ShowMyDragHilite(ev, _fSession->GetDragAndDrop(ev), facet);
-
- return kODTrue;
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope ODDragResult SOMLINK AppleTest_ContainerDragWithin(AppleTest_Container *somSelf, Environment *ev,
- ODDragItemIterator* dragInfo,
- ODFacet* facet,
- ODPoint* where)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DragWithin");
-
- SOM_TRY
-
- ODUnused(dragInfo);
- ODUnused(facet);
- ODUnused(where);
-
- ShowMyDragHilite(ev, _fSession->GetDragAndDrop(ev), facet);
-
- return kODTrue;
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerDragLeave(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* facet,
- ODPoint* where)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DragLeave");
-
- SOM_TRY
-
- ODUnused(where);
-
- HideMyDragHilite(ev, _fSession->GetDragAndDrop(ev), facet);
-
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope ODDropResult SOMLINK AppleTest_ContainerDrop(AppleTest_Container *somSelf, Environment *ev,
- ODDragItemIterator* dropInfo,
- ODFacet* facet,
- ODPoint* where)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","Drop");
-
- SOM_TRY
-
- ODDraft *theDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
- ODULong attributes;
- Point delta, dragPoint, dropPoint, pinnedPoint, newXTrans;
- // short mouseDownModifiers, mouseUpModifiers;
- ODStorageUnit *dropSU = kODNULL;
- ODStorageUnit *newSU = kODNULL;
- ODID draggedFrameID;
- Proxy *p = kODNULL;
- ODFrame *frameDroppedIn;
- TempODFrame newFrame = kODNULL; // DMc refcount - make temp
- ODPart *newPart = kODNULL;
- ODShape *clipShape = kODNULL;
- ODShape *newFrameShape = kODNULL;
-
- ODDropResult dropResult = kODDropMove;
-
- HideMyDragHilite(ev, _fSession->GetDragAndDrop(ev), facet);
-
- // Get the attributes and other crap for this drag
- attributes = _fSession->GetDragAndDrop(ev)->GetDragAttributes(ev);
-
- for (dropSU = dropInfo->First(ev); dropSU;
- dropSU = dropInfo->Next(ev))
- {
- if ((attributes & kODDropIsInSourceFrame) && (attributes & kODDropIsMove))
- {
- // Get where drag started and tweak our own structures to do the move.
- DragReference theDrag = _fSession->GetDragAndDrop(ev)->GetDragReference(ev);
- GetDragOrigin(theDrag, &dragPoint);
- GetDragMouse(theDrag, &dropPoint, &pinnedPoint);
- delta.h = dropPoint.h - dragPoint.h;
- delta.v = dropPoint.v - dragPoint.v;
- dropSU->Focus(ev, kPropFrameInfo, kODPosUndefined, kDrawFrameID, 0, kODPosFirstSib);
- StorageUnitGetValue(dropSU, ev, sizeof(ODID), (ODValue) &draggedFrameID);
- p = somSelf->ProxyForFrameID(ev, draggedFrameID);
-
- // $$$$$ this is a single-facet hack
- ODPoint ODDelta (delta);
- p->transform->MoveBy(ev, &ODDelta);
- TempODTransform newExternalXForm = p->transform->Copy(ev);
- ODFrameFacetIterator* facets = p->frame->CreateFacetIterator(ev);
- facets->First(ev)->ChangeGeometry(ev, kODNULL, newExternalXForm, kODNULL);
- delete facets;
-
- somSelf->UpdateProxyRegion(ev, p);
- somSelf->CreateProxySelectionBorder(ev, p);
-
- dropResult = kODDropMove;
- }
- else
- {
- ODDraft* fromDraft = dropSU->GetDraft(ev);
- ODDraftKey key;
- ODID newPartID;
- ODID newFrameID = 0;
- ODCloneKind cloneKind;
- if (attributes & kODDropIsMove) {
- cloneKind = kODCloneDropMove;
- dropResult = kODDropMove;
- }
- else {
- cloneKind = kODCloneDropCopy;
- dropResult = kODDropCopy;
- }
-
- ODVolatile(fromDraft);
- ODVolatile(key);
-
- #if defined(ODDebug) && ODDebugDrags
- somPrintf("Draw::Drop: Cloning root su\n");
- #endif
- TRY
- key = fromDraft->BeginClone(ev, theDraft, facet->GetFrame(ev), cloneKind);
- newPartID = fromDraft->Clone(ev, key, dropSU->GetID(ev), 0, 0);
- ODID oldPartID = ODGetWeakSURefProp(ev, dropSU, kODPropContentFrame, kODWeakStorageUnitRef);
- if (oldPartID != 0)
- {
- newFrameID = fromDraft->Clone(ev, key, oldPartID, 0, 0);
- }
- fromDraft->EndClone(ev, key);
- CATCH_ALL
- fromDraft->AbortClone(ev, key);
- RERAISE;
- ENDTRY
-
- // Get the mouse down offset from the drop storage unit
- if (ODSUExistsThenFocus(ev, dropSU, kODPropMouseDownOffset, kQDPoint))
- {
- Point mdOffset = {0,0};
- newXTrans = where->AsQDPoint();
-
- // $$$$$ SHOULD USE STDTYPIO FOR STANDARD TYPES LIKE POINTS!
- StorageUnitGetValue(dropSU, ev, sizeof(Point), (ODValue) &mdOffset);
-
- SubPt(mdOffset,&newXTrans);
- }
- else
- {
- newXTrans = where->AsQDPoint();
- }
-
- TempODTransform extXForm = facet->CreateTransform(ev);
- extXForm->SetQDOffset(ev, &newXTrans);
-
- newPart = theDraft->AcquirePart(ev, newPartID);
-
- frameDroppedIn = facet->GetFrame(ev);
-
- if ( newFrameID == 0 )
- {
- if (ODSUExistsThenFocus(ev, dropSU, kODPropSuggestedFrameShape, kODNULL))
- {
- newFrameShape = facet->CreateShape(ev);
- newFrameShape->ReadShape(ev, dropSU);
- }
-
- newFrame = somSelf->MakeEmbeddedFrame(ev, frameDroppedIn,
- newFrameShape, extXForm, newPart, kODFalse);
-
- #if defined(ODDebug) && ODDebugDrags
- somPrintf("Draw %d::Drop: Embedding new frame %d\n", somSelf->GetID(ev), newFrame->GetID(ev));
- #endif
-
- if (newFrameShape)
- {
- newFrameShape->Release(ev);
- newFrameShape = kODNULL;
- }
- }
- else
- {
- #if defined(ODDebug) && ODDebugDrags
- somPrintf("Draw %d::Drop: Embedding cloned frame %d\n", somSelf->GetID(ev), newFrameID);
- #endif
- newFrame = theDraft->AcquireFrame(ev, newFrameID); // DMc refcount - use temp
- newFrame->SetContainingFrame(ev, frameDroppedIn);
- // Must be before AcquirePart, because then Connected is called, and fNeedsActivating is set
-
-
- { TempODPart tempPart = newFrame->AcquirePart(ev); // DMc refcount - make temp
- WASSERTM((newPart == (ODPart*) tempPart), "Draw::Drop - Embedded frame not display frame of embedded part" );
- }
- newFrame->SetDragging(ev, kODFalse);
- newFrame->SetInLimbo(ev, kODFalse);
- somSelf->CreateFrameProxy(ev, (ODFrame*) newFrame, extXForm); // DMc refcount - cast temp to ptr
- }
-
- #if defined(ODDebug) && ODDebugDrags
- somPrintf("Draw %d::Drop: Creating facets\n", somSelf->GetID(ev));
- #endif
- newFrameShape = newFrame->AcquireFrameShape(ev, kODNULL);
- clipShape = newFrameShape->Copy(ev);
-
- TempODTransform copyXForm = somSelf->ProxyForFrame(ev, (ODFrame*) newFrame)->transform->Copy(ev); // DMc refcount - cast temp to ptr
- ODFacet* newFacet = facet->CreateEmbeddedFacet(ev, (ODFrame*) newFrame, clipShape, copyXForm,
- kODNULL, kODNULL, kODNULL, kODFrameInFront);
- frameDroppedIn->Invalidate(ev, kODNULL, kODNULL);
- newPart->Release(ev);
- newFrameShape->Release(ev); newFrameShape = kODNULL;
- clipShape->Release(ev); clipShape = kODNULL;
-
- #if defined(ODDebug) && ODDebugDrags
- somPrintf("Draw %d::Drop: Activating frame receiving the drop\n", somSelf->GetID(ev));
- #endif
-
- #if defined(ODDebug) && ODDebugActivates
- somPrintf("Draw %d::Drop: Calling IsActive\n", somSelf->GetID(ev));
- #endif
- if (!facet->GetWindow(ev)->IsActive(ev))
- {
- #if defined(ODDebug) && ODDebugActivates
- somPrintf("Draw %d::Drop: Calling Select\n", somSelf->GetID(ev));
- #endif
- facet->GetWindow(ev)->Select(ev);
- }
- //else
- somSelf->ActivateFrame(ev, facet->GetFrame(ev));
-
- #if defined(ODDebug) && ODDebugDrags
- somPrintf("Draw %d::Drop: Invalidating and clipping\n", somSelf->GetID(ev));
- #endif
- ODFrame* selectedFrame = kODNULL;
- Proxy* p = kODNULL;
- OrderedCollectionIterator i(_fSelection);
- p = (Proxy*) i.First();
- if (p != kODNULL) {
- selectedFrame = p->frame;
- if (selectedFrame != kODNULL)
- somSelf->InvalidateSelection(ev, selectedFrame);
- }
- somSelf->EmptySelection(ev);
- if (selectedFrame)
- somSelf->ClipEmbeddedFrames(ev, selectedFrame);
-
- #if defined(ODDebug) && ODDebugDrags
- somPrintf("Draw %d::Drop: Hilighting selected frame\n", somSelf->GetID(ev));
- #endif
- p = somSelf->ProxyForFrame(ev, (ODFrame*) newFrame); // DMc refcount - cast temp to ptr
- _fSelection->AddFirst((ElementType)p);
- newFacet->SetSelected(ev, kODTrue);
- somSelf->CreateProxySelectionBorder(ev, p);
-
- #if defined(ODDebug) && ODDebugDrags
- somPrintf("Draw %d::Drop: Completed; display frames =", somSelf->GetID(ev));
- OrderedCollectionIterator aIter(_fDisplayFrames);
- for (ODFrame* aFrame = (ODFrame*)aIter.First(); aIter.IsNotComplete(); aFrame = (ODFrame*)aIter.Next())
- somPrintf (" %d", aFrame->GetID(ev));
- somPrintf ("\n");
- somPrintf("Draw %d::Drop: embedded frames =", somSelf->GetID(ev));
- OrderedCollectionIterator bIter(_fEmbeddedFrames);
- for (ODFrame* bFrame = (ODFrame*)bIter.First(); bIter.IsNotComplete(); bFrame = (ODFrame*)bIter.Next())
- somPrintf (" %d", bFrame->GetID(ev));
- somPrintf ("\n");
- #endif
- }
- }
- somSelf->GetStorageUnit(ev)->GetDraft(ev)->SetChangedFromPrev(ev);
-
- return dropResult;
-
- SOM_CATCH_ALL_ENDTRY
- return kODDropFail;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerContainingPartPropertiesUpdated(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame,
- ODStorageUnit* propertyUnit)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ContainingPartPropertiesUpdated");
-
- SOM_TRY
-
- ODUnused(frame);
- ODUnused(propertyUnit);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope ODStorageUnit* SOMLINK AppleTest_ContainerAcquireContainingPartProperties(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","AcquireContainingPartProperties");
-
- SOM_TRY
-
- ODUnused(frame);
-
- return kODNULL;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerRevealFrame(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* embeddedFrame,
- ODShape* revealShape)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","RevealFrame");
-
- SOM_TRY
-
- ODUnused(embeddedFrame);
- ODUnused(revealShape);
-
- // $$$$$ THROW(kODErrCannotEmbed);
- return kODFalse;
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerEmbeddedFrameSpec(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* embeddedFrame,
- ODObjectSpec* spec)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","EmbeddedFrameSpec");
-
- SOM_TRY
-
- ODUnused(embeddedFrame);
- ODUnused(spec);
-
- THROW(kODErrCannotEmbed);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope ODEmbeddedFramesIterator* SOMLINK AppleTest_ContainerCreateEmbeddedFramesIterator(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","CreateEmbeddedFramesIterator");
-
- SOM_TRY
-
- ODUnused(frame);
-
- DrawEmbeddedFramesIterator* iter = new DrawEmbeddedFramesIterator;
- iter->InitEmbeddedFramesIterator(ev, somSelf);
- return iter;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerDisplayFrameAdded(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DisplayFrameAdded");
-
- SOM_TRY
-
- #if ODDebug
- somPrintf("Draw %d::DisplayFrameAdded: Added frame %d\n", somSelf->GetID(ev), frame->GetID(ev));
- #endif
-
- TempODPart tempPart = frame->AcquirePart(ev);
- if (tempPart == _fPartWrapper) // frame belongs to me
- {
- OrderedCollectionIterator displayFramesIter(_fDisplayFrames);
- ODFrame* displayFrame = (ODFrame*) displayFramesIter.First();
- if (displayFramesIter.IsNotComplete() == kODFalse) {
- OrderedCollectionIterator contentsIter(_fContents);
- Proxy* proxy;
-
- for (proxy = (Proxy*) contentsIter.First();
- contentsIter.IsNotComplete();
- proxy = (Proxy*) contentsIter.Next())
- {
- #if ODDebug
- somPrintf("Draw %d::DisplayFrameAdded: Setting containing frame of embedded frame %d to %d\n",
- somSelf->GetID(ev), proxy->frame->GetID(ev), frame->GetID(ev));
- #endif
- proxy->frame->SetContainingFrame(ev, frame);
- }
- }
-
- // !!! do something with viewType and partInfo...
- PartInfoRec* pInfo = new PartInfoRec;
- //pInfo->bgClipRegion = frame->AcquireFrameShape(ev, kODNULL)->CopyQDRegion(ev); // <12> was GetQDRegion()
- if (frame->IsRoot(ev))
- {
- pInfo->bgColor = rgbWhite;
- pInfo->fNeedsActivating = kODTrue;
- } else
- pInfo->bgColor = _fDefaultColor;
-
- frame->SetPartInfo(ev, (ODInfoType) pInfo);
- _fDisplayFrames->AddLast(frame);
- frame->Acquire(ev);
- frame->SetDroppable(ev, kODTrue);
-
- if (frame->GetViewType(ev) != _fSession->Tokenize(ev, kODViewAsFrame)) // if frame view is set don't change it
- frame->SetViewType(ev, _fSession->Tokenize(ev, kODViewAsFrame)); // if not, make it viewasframe
- if (frame->GetPresentation(ev) != _fSession->Tokenize(ev, kDrawPresNormal))
- frame->SetPresentation(ev, _fSession->Tokenize(ev, kDrawPresNormal));
-
- //if (frame->AcquireContainingFrame(ev) == kODNULL) // <- watch refcounting
- //{
- // //Wrong place. somSelf->ActivateFrame(ev, frame);
- //}
- }
- else
- THROW(kODErrInvalidFrame);
-
- // render in frame?
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerAttachSourceFrame(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame,
- ODFrame* sourceFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","AttachSourceFrame");
-
- SOM_TRY
-
- if (_fDisplayFrames->Contains(frame)
- && sourceFrame && _fDisplayFrames->Contains(sourceFrame))
- {
- //RCR Note. DrawPart does not currently store embedded
- // frames on a per-containing-frame basis (eg. in the part info
- // of each frame). Since we can't add to the embedded frames list
- // while iterating over it, we make a temporary list here
-
- OrderedCollection* embeddedFrames = new OrderedCollection;
- {
- OrderedCollectionIterator iter(_fEmbeddedFrames);
- for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
- iter.IsNotComplete();
- embeddedFrame = (ODFrame*) iter.Next())
- {
- embeddedFrames->AddLast(embeddedFrame);
- }
- }
-
- OrderedCollectionIterator iter(embeddedFrames);
- for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
- iter.IsNotComplete();
- embeddedFrame = (ODFrame*) iter.Next())
- {
- TempODFrame containingFrame = embeddedFrame->AcquireContainingFrame(ev);
- if (containingFrame == sourceFrame)
- {
- TempODPart embeddedPart = embeddedFrame->AcquirePart(ev);
- TempODShape frameShape = embeddedFrame->AcquireFrameShape(ev, kODNULL);
- TempODShape newShape = frameShape->Copy(ev);
- TempODTransform newXForm = somSelf->ProxyForFrame(ev, embeddedFrame)->transform->Copy(ev);
- TempODFrame newFrame = somSelf->MakeEmbeddedFrame(ev, frame,
- newShape, newXForm, embeddedPart,
- embeddedFrame->IsOverlaid(ev));
- embeddedPart->AttachSourceFrame(ev, newFrame, embeddedFrame);
- }
- }
- delete embeddedFrames; // Delete the copy
- }
- else
- THROW(kODErrInvalidFrame);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerDisplayFrameRemoved(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DisplayFrameRemoved");
-
- SOM_TRY
-
- #if ODDebug
- somPrintf("Draw::DisplayFrameRemoved\n");
- #endif
-
- if (frame != (_fPalette ? _fPalette->GetRootFrame(ev) : kODNULL)) {
- if (_fDisplayFrames->Contains(frame))
- {
- OrderedCollection* embeddedFrames = new OrderedCollection;
- {
- OrderedCollectionIterator iter(_fEmbeddedFrames);
- for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
- iter.IsNotComplete();
- embeddedFrame = (ODFrame*) iter.Next())
- {
- embeddedFrames->AddLast(embeddedFrame);
- }
- }
- OrderedCollectionIterator iter(embeddedFrames);
- for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
- iter.IsNotComplete();
- embeddedFrame = (ODFrame*) iter.Next())
- {
- TempODFrame tempFrame = embeddedFrame->AcquireContainingFrame(ev);
- if (tempFrame == frame)
- {
- somSelf->RemoveEmbeddedFrame(ev, embeddedFrame);
- }
- }
- delete embeddedFrames; // Delete the copy
-
- _fSession->GetArbitrator(ev)->RelinquishFocusSet(ev, _fFocusSet,frame);
-
- ODFrame* clipboardFocus = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fClipboardFocus);
- if ( frame == clipboardFocus )
- {
- _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fClipboardFocus, frame);
- somSelf->FocusLost(ev, _fClipboardFocus, frame);
- }
- ODReleaseObject(ev, clipboardFocus);
-
- PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
- frame->SetPartInfo(ev, (ODInfoType) kODNULL);
- delete pInfo;
- if ( _fDisplayFrames->Remove(frame) )
- frame->Release(ev); // DMc - we just called _fDisplayFrames->Remove(frame);
-
- OrderedCollectionIterator dIter(_fDisplayFrames);
- ODFrame* displayFrame = (ODFrame*) dIter.First();
- if (dIter.IsNotComplete() == kODFalse) {
- somSelf->DestroyPalette(ev);
- }
- }
- else
- THROW(kODErrInvalidFrame);
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerDisplayFrameConnected(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DisplayFrameConnected");
-
- SOM_TRY
-
- // $$$$$ add frame to fDisplayFrames if reference lazily internalized
- #if defined(ODDebug) && ODDebugConnections
- somPrintf("Draw %d::DisplayFrameConnected: Connected frame %d\n", somSelf->GetID(ev), frame->GetID(ev));
- #endif
- if ( !_fDisplayFrames->Contains(frame) )
- {
- _fDisplayFrames->AddLast(frame);
- frame->Acquire(ev);
- frame->SetDroppable(ev, kODTrue);
-
- // $$$$$ If any of our embedded frames had no containing frame, hook them up now
- // $$$$$ Kludge until I talk to Joshua [cc] THIS SHOULD BE TAKEN OUT
- OrderedCollectionIterator bIter(_fEmbeddedFrames);
- for (ODFrame* embeddedFrame = (ODFrame*)bIter.First(); bIter.IsNotComplete(); embeddedFrame = (ODFrame*)bIter.Next())
- {
- TempODFrame tempFrame = embeddedFrame->AcquireContainingFrame(ev);
- if ( tempFrame == kODNULL )
- {
- embeddedFrame->SetContainingFrame(ev, frame);
- #if defined(ODDebug) && ODDebugConnections
- somPrintf("Draw %d::DisplayFrameConnected: Set containing frame of %d to %d\n",
- somSelf->GetID(ev), embeddedFrame->GetID(ev), frame->GetID(ev));
- #endif
- }
- }
- }
- #if defined(ODDebug) && ODDebugConnections
- else
- somPrintf("Draw %d::DisplayFrameConnected: No reconnection necessary!\n", somSelf->GetID(ev));
- #endif
-
- // hack to allow editor swapping
- ODStorageUnit* su = kODNULL;
- if ( !_fTestDrawSU )
- {
- ODStorageUnit* su = somSelf->GetStorageUnit(ev);
- _fTestDrawSU = su->GetDraft(ev)->AcquireStorageUnit(ev,
- ODGetStrongSURefProp(ev, su, kODPropContents, kKindTestDraw));
- }
- su = _fTestDrawSU;
-
- if (ODSUExistsThenFocus(ev, su, kODPropEmbeddedFrames, 0))
- {
- ODStorageUnitRef aSURef;
- ODULong offset, offsetLimit;
- Point xform;
-
- su->Focus(ev, kODPropEmbeddedFrames,kODPosSame,0,1,kODPosFirstSib);
- offsetLimit = su->GetSize(ev);
- ODShape* newShape = kODNULL;
- for (offset = 0; offset < offsetLimit;)
- {
- su->SetOffset(ev, offset);
- StorageUnitGetValue(su, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
- offset += sizeof(ODStorageUnitRef);
- ODFrame* eFrame =
- su->GetDraft(ev)->AcquireFrame(ev, su->GetIDFromStorageUnitRef(ev, aSURef)); // TÇ: eFrame is consumed below.
-
- su->SetOffset(ev, offset);
- StorageUnitGetValue(su, ev, sizeof(ODPlatformTransform), (ODValue)&xform);
- offset += sizeof(Point);
-
- if ( _fEmbeddedFrames->Contains(eFrame) )
- ODReleaseObject(ev, eFrame);
- else
- {
- _fEmbeddedFrames->AddLast((ElementType)(ODFrame*)eFrame);
-
- ODTransform* transform =
- eFrame->CreateTransform(ev)->SetQDOffset(ev, &xform); // DMc SetQDOffset() returns this. TÇ: transform is consumed below.
-
- TempODShape frameShape = eFrame->AcquireFrameShape(ev, kODNULL);
- if( newShape )
- newShape->CopyFrom(ev, frameShape);
- else
- newShape = frameShape->Copy(ev);
-
- // TÇ: $$$$$ Should really be using CreateFrameProxy.
- newShape->Transform(ev, transform);
- RgnHandle newRegion = newShape->CopyQDRegion(ev);
- _fContents->AddLast((ElementType)(new Proxy(newRegion, (ODFrame*)eFrame, transform))); // TÇ: transform is consumed here.
- }
- }
- if (newShape) newShape->Release(ev); newShape = kODNULL;
-
- }
-
- PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
- if (frame->IsRoot(ev))
- pInfo->fNeedsActivating = kODTrue;
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerDisplayFrameClosed(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DisplayFrameClosed");
-
- SOM_TRY
-
- if (_fDisplayFrames->Contains(frame))
- {
-
- #if defined(ODDebug) && ODDebugConnections
- somPrintf("Draw %d::DisplayFrameClosed: Removing frame %d\n", somSelf->GetID(ev), frame->GetID(ev));
- #endif
-
- OrderedCollection* embeddedFrames = new OrderedCollection;
- {
- OrderedCollectionIterator iter(_fEmbeddedFrames);
- for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
- iter.IsNotComplete();
- embeddedFrame = (ODFrame*) iter.Next())
- {
- embeddedFrames->AddLast(embeddedFrame);
- }
- }
-
- OrderedCollectionIterator iter(embeddedFrames);
- for (ODFrame* embeddedFrame = (ODFrame*) iter.First();
- iter.IsNotComplete();
- embeddedFrame = (ODFrame*) iter.Next())
- {
- TempODFrame tempFrame = embeddedFrame->AcquireContainingFrame(ev);
- if (tempFrame == frame)
- {
- embeddedFrame->Close(ev);
- _fEmbeddedFrames->Remove(embeddedFrame);
- }
- }
- delete embeddedFrames; // Delete the copy
-
- _fSession->GetArbitrator(ev)->RelinquishFocusSet(ev, _fFocusSet, frame);
-
- ODFrame* clipboardFocus = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fClipboardFocus);
- if ( frame == clipboardFocus )
- {
- _fSession->GetArbitrator(ev)->RelinquishFocus(ev, _fClipboardFocus, frame);
- somSelf->FocusLost(ev, _fClipboardFocus, frame);
- }
- ODReleaseObject(ev, clipboardFocus);
-
- PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
- frame->SetPartInfo(ev, (ODInfoType) kODNULL);
- delete pInfo;
- _fDisplayFrames->Remove(frame);
- ODReleaseObject(ev,frame); // DMc - we just called _fDisplayFrames->Remove(frame);
- }
- else
- THROW(kODErrInvalidFrame);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerFrameShapeChanged(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","FrameShapeChanged");
-
- SOM_TRY
-
- if (_fDisplayFrames->Contains(frame))
- {
- /// !!! should leave UsedShape and ActiveShape null to inherit FrameShape
- // ODShape* scratch;
- // scratch = new ODShape();
- // scratch->CopyFrom(frame->AcquireFrameShape(ev, kODNULL));
- // frame->ChangeUsedShape(ev, scratch);
- // scratch = new ODShape();
- // scratch->CopyFrom(frame->AcquireFrameShape(ev, kODNULL));
- // frame->ChangeActiveShape(ev, scratch);
- }
- else
- THROW(kODErrInvalidFrame);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerViewTypeChanged(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ViewTypeChanged");
-
- SOM_TRY
-
- if (_fDisplayFrames->Contains(frame))
- { /* $$$$$ change viewType of frame */ }
- else
- THROW(kODErrInvalidFrame);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerPresentationChanged(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","PresentationChanged");
-
- SOM_TRY
-
- if (_fDisplayFrames->Contains(frame))
- { /* $$$$$ change presentation of frame */ }
- else
- THROW(kODErrInvalidFrame);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerSequenceChanged(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","SequenceChanged");
-
- SOM_TRY
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope ODInfoType SOMLINK AppleTest_ContainerReadPartInfo(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame,
- ODStorageUnitView* storageUnitView)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ReadPartInfo");
-
- SOM_TRY
-
- ODUnused(frame);
- ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
- TempODPropertyName propName = storageUnitView->GetProperty(ev);
-
- PartInfoRec* partInfo = new PartInfoRec;
- RGBColor forDebuggingRGBColor = rgbRed;
- if ( ODSUExistsThenFocus(ev, su, propName, kKindTestDraw) )
- {
- StorageUnitGetValue(su, ev, sizeof(RGBColor),
- (ODValue)&forDebuggingRGBColor);
- // StorageUnitViewGetValue(storageUnitView, ev, sizeof(RGBColor),
- // (ODValue)&(partInfo->bgColor));
- /*
- ODBoolean needsActivating;
- StorageUnitViewGetValue(storageUnitView, ev, sizeof(ODBoolean),
- (ODValue)&(needsActivating));
- partInfo->fNeedsActivating = needsActivating;
-
- OrderedCollectionIterator d(_fDisplayFrames);
- ODFrame* dispFrame = (ODFrame*) d.First();
- */
- }
- else
- {
- WARN("Persistent partInfo is missing from this frame. Making one up.");
- }
-
- partInfo->bgColor = forDebuggingRGBColor;
- return (ODInfoType)partInfo;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerWritePartInfo(AppleTest_Container *somSelf, Environment *ev,
- ODInfoType partInfo,
- ODStorageUnitView* storageUnitView)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","WritePartInfo");
-
- SOM_TRY
-
- if ( partInfo )
- {
- ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
- TempODPropertyName propName = storageUnitView->GetProperty(ev);
-
- ODSUForceFocus(ev, su, propName, kKindTestDraw);
-
- RGBColor forDebuggingRGBColor ;
- forDebuggingRGBColor = ((PartInfoRec*)partInfo)->bgColor;
- StorageUnitSetValue(su, ev, sizeof(RGBColor), (ODValue)&forDebuggingRGBColor);
- /*
- ODBoolean needsActivating = ((PartInfoRec*)partInfo)->fNeedsActivating
- || ((PartInfoRec*)partInfo)->fIsActive;
- StorageUnitViewSetValue(storageUnitView, ev, sizeof(ODBoolean),
- (ODValue)&needsActivating);
- */
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerClonePartInfo(AppleTest_Container *somSelf, Environment *ev,
- ODDraftKey key,
- ODInfoType partInfo,
- ODStorageUnitView* storageUnitView,
- ODFrame* scopeFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","WritePartInfo");
-
- SOM_TRY
-
- if (partInfo)
- {
- ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
- TempODPropertyName propName = storageUnitView->GetProperty(ev);
-
- ODSUForceFocus(ev, su, propName, kKindTestDraw);
-
- RGBColor forDebuggingRGBColor ;
- forDebuggingRGBColor = ((PartInfoRec*)partInfo)->bgColor;
- StorageUnitSetValue(su, ev, sizeof(RGBColor), (ODValue)&forDebuggingRGBColor);
- /*
- ODBoolean needsActivating = ((PartInfoRec*)partInfo)->fNeedsActivating
- || ((PartInfoRec*)partInfo)->fIsActive;
- StorageUnitViewSetValue(storageUnitView, ev, sizeof(ODBoolean),
- (ODValue)&needsActivating);
- */
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope ODID SOMLINK AppleTest_ContainerOpen(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","Open");
-
- SOM_TRY
-
- TempODWindow window = kODNULL;
- ODID windowID = 0;
-
- if (frame) // Doing a View As Window or Open Root
- {
- if (frame->IsRoot(ev)) // Create Window For Root Frame
- {
- WindowProperties props;
- if (BeginGetWindowProperties(ev, frame, &props))
- {
- ODPlatformWindow platformWindow = NewCWindow(kODNULL, &(props.boundsRect), props.title,
- kODFalse, props.procID, (WindowPtr)-1L, props.hasCloseBox, props.refCon);
-
-
- window = _fSession->GetWindowState(ev)->RegisterWindowForFrame(ev, platformWindow,
- frame,
- props.isRootWindow, // Keeps draft open
- kODTrue, // Is resizable
- kODFalse, // Is floating
- kODTrue, // should save
- kODTrue, // should dispose
- props.sourceFrame);
- EndGetWindowProperties(ev, &props); // Release source frame
- window->Open(ev);
- }
- else
- {
- Rect windRect;
- SetRect(&windRect, 100, 100, 300, 300);
- ODPlatformWindow platformWindow = NewCWindow(kODNULL, &windRect, "\p", kODFalse, zoomDocProc, (WindowPtr)-1L, true, kODNULL);
-
- window = _fSession->GetWindowState(ev)->RegisterWindowForFrame(ev, platformWindow,
- frame,
- kODTrue, // Keeps draft open
- kODTrue, // Is resizable
- kODFalse, // Is floating
- kODTrue, // should save
- kODTrue, // should dispose
- kODNULL);
- window->Open(ev);
- window->AdjustWindowShape(ev);
- }
- window->Show(ev);
- }
- else // View In Window
- {
- window = _fSession->GetWindowState(ev)->AcquireWindow(ev, _fWindowID);
- if (window)
- {
- window->Select(ev);
- }
- else
- {
- window = somSelf->CreateWindow(ev, frame);
- _fWindowID = window->GetID(ev);
- window->Open(ev);
- window->Show(ev);
- window->Select(ev);
- }
- }
- }
- else
- {
- window = somSelf->CreateWindow(ev, frame);
- _fWindowID = window->GetID(ev);
- window->Open(ev);
- window->Show(ev);
- window->Select(ev);
- }
- windowID = window->GetID(ev);
- return windowID;
-
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULLID;
- }
-
- SOM_Scope ODFrame* SOMLINK AppleTest_ContainerRequestEmbeddedFrame(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* containingFrame,
- ODFrame* baseFrame,
- ODShape* frameShape,
- ODPart* embedPart,
- ODTypeToken viewType,
- ODTypeToken presentation,
- ODBoolean isOverlaid)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","RequestEmbeddedFrame");
-
- SOM_TRY
-
- ODFrame* embeddedFrame;
- ODTransform* externalXForm = containingFrame->CreateTransform(ev);
-
- ODSLong count = 1 + _fContents->Count();
-
- Point ptTemp;
- SetPt(&ptTemp,(short)(count*20),(short)(count*20));
- externalXForm->SetQDOffset(ev, &ptTemp);
- embeddedFrame = somSelf->MakeEmbeddedFrame(ev,
- containingFrame,
- frameShape,
- externalXForm,
- embedPart,
- isOverlaid);
-
- embeddedFrame->SetViewType(ev, viewType);
- embeddedFrame->SetPresentation(ev, presentation);
-
- ODFrameFacetIterator* facets = containingFrame->CreateFacetIterator(ev);
- for (ODFacet* facet = facets->First(ev); facets->IsNotComplete(ev);
- facet = facets->Next(ev))
- {
- TempODShape frameShape = embeddedFrame->AcquireFrameShape(ev, kODNULL);
- TempODShape clip = frameShape->Copy(ev);
- TempODTransform xform = somSelf->ProxyForFrame(ev, embeddedFrame)->transform->Copy(ev);
- facet->CreateEmbeddedFacet(ev, embeddedFrame, clip, xform,
- kODNULL, kODNULL, kODNULL, kODFrameInFront);
- }
- delete facets;
- somSelf->ClipEmbeddedFrames(ev, containingFrame);
- containingFrame->Invalidate(ev, kODNULL, kODNULL);
-
-
- return embeddedFrame;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerRemoveEmbeddedFrame(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* embeddedFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","RemoveEmbeddedFrame");
-
- SOM_TRY
-
- TempODFrame containingFrame = embeddedFrame->AcquireContainingFrame(ev);
-
- embeddedFrame->Acquire(ev);
-
- somSelf->DeleteFrameProxy(ev, somSelf->ProxyForFrame(ev, embeddedFrame));
-
- embeddedFrame->Remove(ev);
-
- somSelf->ClipEmbeddedFrames(ev, containingFrame);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope ODShape* SOMLINK AppleTest_ContainerRequestFrameShape(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* embeddedFrame,
- ODShape* frameShape)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","RequestFrameShape");
-
- SOM_TRY
-
- if (_fEmbeddedFrames->Contains(embeddedFrame))
- { // find frame proxy and fix cached region
- Proxy* p = somSelf->ProxyForFrame(ev, embeddedFrame);
- if (p)
- {
- ODShape* scratch = frameShape->Copy(ev);
- scratch->Transform(ev, p->transform);
- p->region = scratch->CopyQDRegion(ev);
- scratch->Release(ev); scratch = kODNULL;
-
- p->frame->Invalidate(ev, kODNULL, kODNULL);
- // p->frame->Invalidate(ev, frameShape, kODNULL); // $$$$$ why do we need this?
-
- if (_fSelection->Contains(p)) { /* !!! fix highlighting */ };
-
- // fix clipping of obscured frames
- TempODFrame tempFrame = embeddedFrame->AcquireContainingFrame(ev);
- somSelf->ClipEmbeddedFrames(ev, tempFrame);
- }
- }
- else
- THROW(kODErrInvalidFrame);
-
- frameShape->Acquire(ev);
- return frameShape;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerUsedShapeChanged(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* embeddedFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","UsedShapeChanged");
-
- SOM_TRY
-
- if (_fEmbeddedFrames->Contains(embeddedFrame))
- {
- TempODFrame tempFrame = embeddedFrame->AcquireContainingFrame(ev);
- somSelf->ClipEmbeddedFrames(ev, tempFrame);
- }
- else
- THROW(kODErrInvalidFrame);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope ODShape* SOMLINK AppleTest_ContainerAdjustBorderShape(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* embeddedFacet,
- ODShape* shape)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","AdjustBorderShape");
-
- SOM_TRY
-
- if ( embeddedFacet == kODNULL )
- THROW(kODErrIllegalNullInput); // $$$$$ kODErrIllegalNullFacetInput
-
- ODFacet* dispFacet = embeddedFacet->GetContainingFacet(ev);
-
- TempODPart tempPart = dispFacet->GetFrame(ev)->AcquirePart(ev); // for ASSERT below
- ASSERT(tempPart == _fPartWrapper, kODErrInvalidFacet);
-
- if ( shape == kODNULL )
- return kODNULL;
-
- TempODShape adjusted = shape->Copy(ev);
- ODShape* returnValue = kODNULL;
-
- { TempODTransform xform = embeddedFacet->AcquireExternalTransform(ev, kNoBias);
- adjusted->Transform(ev, xform);
- }
-
- { TempODShape dispShape = dispFacet->GetFrame(ev)->AcquireUsedShape(ev, kNoBias);
- adjusted->Intersect(ev, dispShape);
- }
-
- ODFacet* facet = kODNULL;
- ODBoolean above = kODFalse;
- ODFacetIterator* facets = dispFacet->CreateFacetIterator(ev, kODChildrenOnly, kODBackToFront);
- for (facet = facets->First(ev);
- facets->IsNotComplete(ev);
- facet = facets->Next(ev))
- {
- if ( above )
- {
- TempODShape tShape = ODCopyAndRelease(ev, facet->GetFrame(ev)->AcquireUsedShape(ev, kNoBias));
- TempODTransform xform = facet->AcquireExternalTransform(ev, kNoBias);
- tShape->Transform(ev, xform);
- adjusted->Subtract(ev, tShape);
- }
- else
- {
- above = ( facet == embeddedFacet );
- }
- }
- delete facets;
-
- { TempODTransform xform = embeddedFacet->AcquireExternalTransform(ev, kNoBias);
- adjusted->InverseTransform(ev, xform);
- }
-
- returnValue = adjusted; adjusted = kODNULL;
-
- return returnValue;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerFacetAdded(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* facet)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","FacetAdded");
-
- SOM_TRY
-
- #if defined(ODDebug) && ODDebugConnections
- somPrintf("Draw %d::FacetAdded: Added facet %x; display frames =", somSelf->GetID(ev), facet);
- OrderedCollectionIterator aIter(_fDisplayFrames);
- for (ODFrame* aFrame = (ODFrame*)aIter.First(); aIter.IsNotComplete(); aFrame = (ODFrame*)aIter.Next())
- somPrintf (" %d", aFrame->GetID(ev));
- somPrintf ("\n");
- #endif
-
- ODFrame* dispFrame = facet->GetFrame(ev);
- if (!_fDisplayFrames->Contains(dispFrame))
- THROW(kODErrInvalidFacet);
-
- OrderedCollectionIterator frames(_fEmbeddedFrames);
- for (ODFrame* frame = (ODFrame*) frames.First();
- frames.IsNotComplete();
- frame = (ODFrame*) frames.Next())
- {
- TempODFrame tempFrame = frame->AcquireContainingFrame(ev);
- if (tempFrame == dispFrame)
- {
- TempODShape frameShape = frame->AcquireFrameShape(ev, kODNULL);
- TempODShape clip = frameShape->Copy(ev);
- Proxy* p = somSelf->ProxyForFrame(ev, frame);
- TempODTransform xform = p->transform->Copy(ev);
- facet->CreateEmbeddedFacet(ev, frame,
- clip, xform, kODNULL, kODNULL,
- kODNULL, kODFrameBehind);
- }
- }
-
- somSelf->ClipEmbeddedFacets(ev, facet);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerFacetRemoved(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* facet)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","FacetRemoved");
-
- SOM_TRY
-
- #if defined(ODDebug) && ODDebugConnections
- somPrintf("Draw %d::FacetRemoved: Facet %x removed; display frames =", somSelf->GetID(ev) , facet);
- OrderedCollectionIterator aIter(_fDisplayFrames);
- for (ODFrame* aFrame = (ODFrame*)aIter.First(); aIter.IsNotComplete(); aFrame = (ODFrame*)aIter.Next())
- somPrintf (" %d", aFrame->GetID(ev));
- somPrintf ("\n");
- #endif
-
- ODFrame* dispFrame = facet->GetFrame(ev);
- if (!_fDisplayFrames->Contains(dispFrame))
- {
- #if defined(ODDebug) && ODDebugConnections
- somPrintf("Draw::FacetRemoved: Frame ID = %d is not a display frame\n", dispFrame->GetID(ev));
- #endif
- THROW(kODErrInvalidFacet);
- }
-
- OrderedCollection* children = new OrderedCollection;
- ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
- ODFacet* childFacet;
- for (childFacet = facets->First(ev);
- facets->IsNotComplete(ev);
- childFacet = facets->Next(ev))
- {
- children->AddLast(childFacet);
- }
- delete facets;
- OrderedCollectionIterator iter(children);
- for (childFacet = (ODFacet*)iter.First();
- iter.IsNotComplete();
- childFacet = (ODFacet*)iter.Next())
- {
- facet->RemoveFacet(ev, childFacet);
- delete childFacet;
- }
- delete children;
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerCanvasChanged(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* facet)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","CanvasChanged");
-
- SOM_TRY
-
- ODUnused(facet);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerGeometryChanged(AppleTest_Container *somSelf,
- Environment *ev, ODFacet* facet,
- ODBoolean clipShapeChanged,
- ODBoolean externalTransformChanged)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","GeometryChanged");
-
- SOM_TRY
-
- facet->Invalidate(ev, kODNULL, kODNULL);
-
- somSelf->ClipEmbeddedFacets(ev, facet); // extra work, but gives correct display
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerDraw(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* facet,
- ODShape* invalidShape)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","Draw");
-
- SOM_TRY
-
- ODBoolean drawing = facet->GetCanvas(ev)->IsDynamic(ev);
-
- ODUnused(invalidShape);
-
- ODFrame* displayFrame = facet->GetFrame(ev);
- if (_fDisplayFrames->Contains(displayFrame))
- {
- // transform grafport
-
- CFocus prepareForRendering(ev, facet);
-
- RgnHandle bRgn;
-
- { TempODShape frameShape = displayFrame->AcquireFrameShape(ev, kODNULL); // DMc refcount - make temp
- bRgn = frameShape->GetQDRegion(ev);
- }
-
- if ((drawing) && (displayFrame->GetPresentation(ev) == _fSession->Tokenize(ev, kDrawPresPalette)))
- {
- Rect bRect;
- Rect colorRect;
- ODUShort i;
- RGBColor bgColor;
- ODSShort height;
- OSErr err = noErr;
-
- RGBBackColor(&rgbBlack);
- EraseRgn(bRgn);
-
- bRect.left = (**bRgn).rgnBBox.left;
- bRect.top = (**bRgn).rgnBBox.top;
- bRect.bottom = (**bRgn).rgnBBox.bottom;
- bRect.right = (**bRgn).rgnBBox.right;
-
- height = ((bRect.bottom - bRect.top) - kMargin - ((kNumColors-1) * kMargin) - kMargin) / kNumColors;
-
- colorRect.left = bRect.left + kMargin;
- colorRect.right = bRect.right - kMargin;
- colorRect.top = bRect.top + kMargin;
- colorRect.bottom = colorRect.top + height;
-
- for (i = 0; i < kNumColors; i++) {
- somSelf->GetBGColor(ev, i, &bgColor);
- RGBBackColor(&bgColor);
- EraseRect(&colorRect);
- colorRect.top = colorRect.bottom + kMargin;
- colorRect.bottom = colorRect.top + height;
- }
- RGBBackColor(&rgbWhite);
- }
- else // <eeh> removed the following test until Joshua fixes frame presentation externalization
- // if ( facet->GetFrame(ev)->GetPresentation(ev) == _fSession->Tokenize(ev, kDrawPresNormal) )
- {
- ODTypeToken curView = displayFrame->GetViewType(ev);
- // $$$$$ until Joshua fixes...see above
- if (curView == _fSession->Tokenize(ev, kODViewAsLargeIcon))
- {
- Rect rect32;
- SetRect(&rect32, 0, 0, kODLargeIconSize, kODLargeIconSize);
- PlotIconSuite(&rect32,atAbsoluteCenter,ttNone,_fLargeIcons);
- }
- else if (curView == _fSession->Tokenize(ev, kODViewAsSmallIcon))
- {
- Rect rect16;
- SetRect(&rect16, 0, 0, kODSmallIconSize, kODSmallIconSize);
- PlotIconSuite(&rect16,atAbsoluteCenter,ttNone,_fSmallIcons);
- }
- else // if (curView == _fSession->Tokenize(ev, kODViewAsFrame))
- {
- PartInfoRec* pInfo = (PartInfoRec*) displayFrame->GetPartInfo(ev);
-
- // paint the background
-
- PenNormal();
-
- RGBColor saveRGB;
- GetBackColor(&saveRGB);
- RGBColor bgRGB = pInfo->bgColor;
-
- RGBBackColor(&bgRGB);
- EraseRect(&(**bRgn).rgnBBox);
- RGBBackColor(&saveRGB); // restore old bg color
-
- #if ODDebug
- // !!! test code for debugging help
- // display frame and facet object addresses
- char splat[96];
-
- PenNormal();
- TextFace( normal );
- TextFont( courier );
- TextMode( srcOr );
- TextSize( 9 );
- short vertical = 0;
-
- // Inflated by 1 because dispatcher has acquired window
- sprintf(splat, "Window: <%p> [%d]", facet->GetWindow(ev), (facet->GetWindow(ev)->GetRefCount(ev) - 1));
- MoveTo( 4, vertical+=12 );
- DrawText( &splat, 0, strlen(splat) );
-
- // this part's refcount is inflated by 1 from Facet::Draw calling AcquirePart
- sprintf(splat, "part: <%p> [%d]", somSelf, (somSelf->GetRefCount(ev) - 1));
- MoveTo( 4, vertical+=12 );
- DrawText( &splat, 0, strlen(splat) );
-
- sprintf(splat, "wrap: <%p>", _fPartWrapper);
- MoveTo( 4, vertical+=12 );
- DrawText( &splat, 0, strlen(splat) );
-
- ODFrame* printFrame = facet->GetFrame(ev);
- sprintf(splat, "frame: <%p> [%d]", printFrame, printFrame->GetRefCount(ev));
- MoveTo( 4, vertical+=12 );
- DrawText( &splat, 0, strlen(splat) );
-
- {
- TempODShape tempShape = printFrame->AcquireFrameShape(ev, kODNULL);
- sprintf(splat, " framShape: [%d]", (tempShape->GetRefCount(ev) - 1));
- MoveTo( 4, vertical+=12 );
- DrawText( &splat, 0, strlen(splat) );
- }
-
- {
- TempODShape tempShape = printFrame->AcquireUsedShape(ev, kODNULL);
- sprintf(splat, " usedShape: [%d]", (tempShape->GetRefCount(ev) - 1));
- MoveTo( 4, vertical+=12 );
- DrawText( &splat, 0, strlen(splat) );
- }
-
- {
- TempODTransform tempXForm = printFrame->AcquireInternalTransform(ev, kODNULL);
- sprintf(splat, " intXForm: [%d]", (tempXForm->GetRefCount(ev) - 1));
- MoveTo( 4, vertical+=12 );
- DrawText( &splat, 0, strlen(splat) );
- }
-
- sprintf(splat, "facet: <%p>", facet);
- MoveTo( 4, vertical+=12 );
- DrawText( &splat, 0, strlen(splat) );
-
- {
- TempODShape tempShape = facet->AcquireClipShape(ev, kODNULL);
- sprintf(splat, " clipShape: [%d]", (tempShape->GetRefCount(ev) - 1));
- MoveTo( 4, vertical+=12 );
- DrawText( &splat, 0, strlen(splat) );
- }
-
- {
- TempODShape tempShape = facet->AcquireActiveShape(ev, kODNULL);
- sprintf(splat, " actvShape: [%d]", (tempShape->GetRefCount(ev) - 1));
- MoveTo( 4, vertical+=12 );
- DrawText( &splat, 0, strlen(splat) );
- }
-
- {
- TempODTransform tempXForm = facet->AcquireExternalTransform(ev, kODNULL);
- sprintf(splat, " extXForm: [%d]", (tempXForm->GetRefCount(ev) - 1));
- MoveTo( 4, vertical+=12 );
- DrawText( &splat, 0, strlen(splat) );
- }
-
- ODDraft* draft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
- // <eeh> please don't remove ID until it shows up in part/frame info dialog
- ODFrame* frame = facet->GetFrame(ev);
- ODPersistentObjectID id =
- (frame->GetStorageUnit(ev) != kODNULL) ?
- draft->GetPersistentObjectID( ev,
- (ODPersistentObject*)frame, kODFrameObject) :
- frame->GetID(ev);
-
- sprintf(splat, "ID: <%d>", id);
- MoveTo( 4, vertical+=12 );
- DrawText( &splat, 0, strlen(splat) );
-
- if ( facet->GetFrame(ev)->IsRoot(ev) )
- {
- sprintf(splat, "draft: <%p> [%d]", draft, draft->GetRefCount(ev));
- MoveTo( 4, vertical+=12 );
- DrawText( &splat, 0, strlen(splat) );
- }
-
- TextSize(12);
- ODIText* iText = ODGetComments( ev, facet->GetFrame(ev), kODNULL );
- if (iText != kODNULL)
- {
- MoveTo( 4, vertical+=16 );
- DrawText(GetITextPtr(iText), 0, GetITextStringLength(iText) );
- DisposeIText(iText);
- }
- TextSize(9);
-
-
- ODFacet* child = kODNULL;
- ODFacetIterator* facets = facet->CreateFacetIterator(ev, kODChildrenOnly, kODFrontToBack);
- THROW_IF_NULL(facets);
- for ( child = facets->First(ev); facets->IsNotComplete(ev); child = facets->Next(ev) )
- {
- TempODTransform txf = child->AcquireExternalTransform(ev, kODNULL);
- Point bob = txf->GetQDOffset(ev);
-
- TempODShape tfs = child->GetFrame(ev)->AcquireFrameShape(ev, kODNULL);
- RgnHandle obo = tfs->GetQDRegion(ev);
- bob.v += (**obo).rgnBBox.bottom;
-
- ODFrame* childFrame = child->GetFrame(ev);
- ODPart* childPart = childFrame->AcquirePart(ev);
- sprintf(splat, "part: <%p> [%d]", childPart, (childPart->GetRefCount(ev) - 1));
- MoveTo( bob.h, bob.v+=12 );
- DrawText( &splat, 0, strlen(splat) );
- ODReleaseObject(ev, childPart);
-
- sprintf(splat, "frame: <%p> [%d]", childFrame, childFrame->GetRefCount(ev));
- MoveTo( bob.h, bob.v+=12 );
- DrawText( &splat, 0, strlen(splat) );
-
- {
- TempODShape tempShape = childFrame->AcquireFrameShape(ev, kODNULL);
- sprintf(splat, " framShape: [%d]", (tempShape->GetRefCount(ev) - 2));
- MoveTo( bob.h, bob.v+=12 );
- DrawText( &splat, 0, strlen(splat) );
- }
-
- {
- TempODShape tempShape = childFrame->AcquireUsedShape(ev, kODNULL);
- sprintf(splat, " usedShape: [%d]", (tempShape->GetRefCount(ev) - 1));
- MoveTo( bob.h, bob.v+=12 );
- DrawText( &splat, 0, strlen(splat) );
- }
-
- {
- TempODTransform tempXForm = childFrame->AcquireInternalTransform(ev, kODNULL);
- sprintf(splat, " intXForm: [%d]", (tempXForm->GetRefCount(ev) - 1));
- MoveTo( bob.h, bob.v+=12 );
- DrawText( &splat, 0, strlen(splat) );
- }
-
- sprintf(splat, "facet: <%p>", child);
- MoveTo( bob.h, bob.v+=12 );
- DrawText( &splat, 0, strlen(splat) );
-
- {
- TempODShape tempShape = child->AcquireClipShape(ev, kODNULL);
- sprintf(splat, " clipShape: [%d]", (tempShape->GetRefCount(ev) - 1));
- MoveTo( bob.h, bob.v+=12 );
- DrawText( &splat, 0, strlen(splat) );
- }
-
- {
- TempODShape tempShape = child->AcquireActiveShape(ev, kODNULL);
- sprintf(splat, " actvShape: [%d]", (tempShape->GetRefCount(ev) - 1));
- MoveTo( bob.h, bob.v+=12 );
- DrawText( &splat, 0, strlen(splat) );
- }
-
- {
- TempODTransform tempXForm = child->AcquireExternalTransform(ev, kODNULL);
- sprintf(splat, " extXForm: [%d]", (tempXForm->GetRefCount(ev) - 2));
- MoveTo( bob.h, bob.v+=12 );
- DrawText( &splat, 0, strlen(splat) );
- }
-
- }
- ODDeleteObject(facets);
- #endif
-
- // no intrinsic contents, so just highlight the selection
-
- ODFrame* activeFrame = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fSelectionFocus);
- if (displayFrame == activeFrame)
- { // drawing active frame - highlight selection
- somSelf->HighlightSelection(ev);
- }
- else
- { // drawing inactive frame - do nothing for now
- }
- ODReleaseObject(ev, activeFrame);
- }
- }
- }
- else
- {
- // !!! signal error: invalid frame
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerCanvasUpdated(AppleTest_Container *somSelf, Environment *ev,
- ODCanvas* canvas)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","CanvasUpdated");
-
- SOM_TRY
-
- ODUnused(canvas);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerHighlightChanged(AppleTest_Container *somSelf, Environment *ev,
- ODFacet* facet)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HighlightChanged");
-
- SOM_TRY
-
- ODUnused(facet);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope ODULong SOMLINK AppleTest_ContainerGetPrintResolution(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","GetPrintResolution");
-
- SOM_TRY
-
- ODUnused(frame);
-
- return 0;
-
- SOM_CATCH_ALL_ENDTRY
- return 0;
- }
-
- SOM_Scope ODLinkSource* SOMLINK AppleTest_ContainerCreateLink(AppleTest_Container *somSelf, Environment *ev,
- ODByteArray* data)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","CreateLink");
-
- SOM_TRY
-
- ODUnused(data);
-
- return nil;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerLinkUpdated(AppleTest_Container *somSelf, Environment *ev,
- ODLink* updatedLink,
- ODUpdateID change)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","LinkUpdated");
-
- SOM_TRY
-
- ODUnused(updatedLink);
- ODUnused(change);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerRevealLink(AppleTest_Container *somSelf, Environment *ev,
- ODLinkSource* linkSource)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","RevealLink");
-
- SOM_TRY
-
- ODUnused(linkSource);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerEmbeddedFrameUpdated(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame,
- ODUpdateID change)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","EmbeddedFrameUpdated");
-
- SOM_TRY
-
- ODUnused(change);
- ODUnused(frame);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerLinkStatusChanged(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","LinkStatusChanged");
-
- SOM_TRY
-
- ODUnused(frame);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerBeginRelinquishFocus(AppleTest_Container *somSelf, Environment *ev,
- ODTypeToken focus,
- ODFrame* ownerFrame,
- ODFrame* proposedFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","BeginRelinquishFocus");
-
- SOM_TRY
-
- ODUnused(focus);
- ODUnused(ownerFrame);
- ODUnused(proposedFrame);
-
- return kODTrue;
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerCommitRelinquishFocus(AppleTest_Container *somSelf, Environment *ev,
- ODTypeToken focus,
- ODFrame* ownerFrame,
- ODFrame* proposedFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","CommitRelinquishFocus");
-
- SOM_TRY
-
- ODUnused(proposedFrame);
-
- somSelf->FocusLost(ev, focus, ownerFrame);
- if (focus != _fClipboardFocus)
- somSelf->HidePalette(ev);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerAbortRelinquishFocus(AppleTest_Container *somSelf, Environment *ev,
- ODTypeToken focus,
- ODFrame* ownerFrame,
- ODFrame* proposedFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","AbortRelinquishFocus");
-
- SOM_TRY
-
- ODUnused(focus);
- ODUnused(ownerFrame);
- ODUnused(proposedFrame);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerFocusAcquired(AppleTest_Container *somSelf, Environment *ev,
- ODTypeToken focus,
- ODFrame* ownerFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","FocusAcquired");
-
- SOM_TRY
-
- Proxy* sp = kODNULL;
-
- if (focus == _fSelectionFocus)
- {
- PartInfoRec* pInfo = (PartInfoRec*) ownerFrame->GetPartInfo(ev);
- pInfo->fIsActive = kODTrue;
-
- if ( _fSelection )
- sp = (Proxy*) _fSelection->First();
- if ( sp )
- {
- somSelf->CreateProxySelectionBorder(ev, sp);
- somSelf->ClipEmbeddedFrames(ev, ownerFrame);
- }
-
- somSelf->ShowPalette(ev);
- }
- else if (focus == _fMenuFocus)
- somSelf->InstallMenus(ev, ownerFrame);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerFocusLost(AppleTest_Container *somSelf, Environment *ev,
- ODTypeToken focus,
- ODFrame* ownerFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","FocusLost");
-
- SOM_TRY
-
- if (focus == _fSelectionFocus)
- {
- PartInfoRec* pInfo = (PartInfoRec*) ownerFrame->GetPartInfo(ev);
- pInfo->fIsActive = kODFalse;
- somSelf->InvalidateSelection(ev, ownerFrame);
- somSelf->EmptySelection(ev);
- SetEmptyRgn(_fSelectRgn);
- SetEmptyRgn(_fCornerHandleRgn);
- SetEmptyRgn(_fEdgeHandleRgn);
- somSelf->ClipEmbeddedFrames(ev, ownerFrame);
-
- somSelf->HidePalette(ev);
- }
- else if (focus == _fMenuFocus)
- {
- somSelf->RemoveMenus(ev, ownerFrame);
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerCloneInto(AppleTest_Container *somSelf, Environment *ev,
- ODDraftKey key,
- ODStorageUnit* toSU,
- ODFrame* scopeFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","CloneInto");
-
- SOM_TRY
-
- parent_CloneInto(somSelf,ev,key,toSU,scopeFrame);
-
- if ( !toSU->Exists(ev, kODPropContents, kKindTestDraw, 0) )
- {
- // $$$$$ For the MacTech seed CD, don't promise content so linked content
- // is cloned correctly.
- #ifndef BETASEEDMODS
- if ( toSU->Exists(ev, kODPropContentFrame, kODWeakStorageUnitRef, 0) )
- {
- // This part is being cloned as a single embedded part, so promise our content.
- // #if ODDebug
- // somPrintf("Draw %d::CloneInto: Promising content\n", somSelf->GetID(ev));
- // #endif
- if ( !toSU->Exists(ev, kODPropContents, kODNULL, 0) )
- toSU->AddProperty(ev, kODPropContents);
- // $$$$$ Should store the scopeFrame as the promise value so FulFill promise
- // can enforce scope restrictions correctly.
- ODSShort dummy = 0;
- StorageUnitSetPromiseValue(toSU, ev, kKindTestDraw, 0, 0, kODNULL, somSelf);
- }
- else
- #endif
- {
- #if ODDebug
- somPrintf("Draw %d::CloneInto: Cloning content to %d %d\n", somSelf->GetID(ev), toSU, scopeFrame);
- #endif
- TempODStorageUnit testDrawContentSU = toSU->GetDraft(ev)->CreateStorageUnit(ev);
- somSelf->CloneTestDrawContent(ev, key, testDrawContentSU, scopeFrame);
-
- ODSetStrongSURefProp(ev, toSU, kODPropContents, kKindTestDraw, testDrawContentSU->GetID(ev));
- #if ODDebug
- somPrintf("Draw %d::CloneInto: Cloning Done\n", somSelf->GetID(ev));
- #endif
- }
- }
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Draw: CloneTestDrawContent
- //------------------------------------------------------------------------------
- SOM_Scope void SOMLINK AppleTest_ContainerCloneTestDrawContent(AppleTest_Container *somSelf, Environment *ev,
- ODDraftKey key,
- ODStorageUnit* toSU,
- ODFrame* scopeFrame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","CloneTestDrawContent");
-
- SOM_TRY
-
- #if ODDebug
- somPrintf("Draw %d::CloneTestDrawContent: Cloning content\n", somSelf->GetID(ev));
- #endif
-
- ODSetBooleanProp(ev, toSU, kPropScriptingOn, kODBoolean, _fScriptingOn);
-
- ODDraft* fromDraft = somSelf->GetStorageUnit(ev)->GetDraft(ev);
- ODDraft* toDraft = toSU->GetDraft(ev);
-
- ODStorageUnitRef aSURef;
- ODULong offset;
- ODFrame* frame;
- Proxy* proxy;
- OrderedCollectionIterator aIter(_fDisplayFrames);
- OrderedCollectionIterator cIter(_fContents);
- Point xform;
- ODID scopeFrameID = ( scopeFrame ? scopeFrame->GetID(ev) : 0 );
-
- ODSUAddPropValue(ev, toSU, kODPropDisplayFrames, kODWeakStorageUnitRef);
-
- offset = 0;
- for (frame = (ODFrame*)aIter.First(); aIter.IsNotComplete();
- frame = (ODFrame*)aIter.Next(), offset+=sizeof(ODStorageUnitRef))
- {
- // $$$$$ Don't copy display frames unless they're in scope;
- // Currently, this part supports only one display frame
- ODID toFrameID = fromDraft->WeakClone(ev, key, frame->GetID(ev), 0, scopeFrameID);
- toSU->GetWeakStorageUnitRef(ev, toFrameID, aSURef);
- toSU->SetOffset(ev, offset);
- StorageUnitSetValue(toSU, ev, sizeof(ODStorageUnitRef), aSURef);
- }
-
- ODSetULongProp(ev, toSU, kODPropFrameGroup, kODULong, _fFrameGroupIDCounter);
-
- ODSUAddPropValue(ev, toSU, kODPropEmbeddedFrames, kODStrongStorageUnitRef);
- offset = 0;
- for (proxy = (Proxy*)cIter.First();
- cIter.IsNotComplete();
- proxy = (Proxy*)cIter.Next())
- {
- #if ODDebug
- somPrintf("Draw %d::CloneTestDrawContent: Clone Proxy: %d\n", somSelf->GetID(ev), proxy->frame->GetID(ev));
- #endif
- ODID id = proxy->frame->GetID(ev);
- ODID toFrameID = fromDraft->Clone(ev, key, id, 0, id);
- toSU->GetStrongStorageUnitRef(ev, toFrameID, aSURef);
- toSU->SetOffset(ev, offset);
- StorageUnitSetValue(toSU, ev, sizeof(ODStorageUnitRef), aSURef);
- offset += sizeof(ODStorageUnitRef);
-
- xform = proxy->transform->GetQDOffset(ev);
- toSU->SetOffset(ev, offset);
- StorageUnitSetValue(toSU, ev, sizeof(ODPlatformTransform), (ODValue)&xform);
- offset += sizeof(Point);
- }
-
- #if ODDebug
- somPrintf("Draw %d::CloneTestDrawContent: Done\n", somSelf->GetID(ev));
- #endif
-
- SOM_CATCH_ALL
- PRINT("Draw %d::CloneTestDrawContent: Exception caught\n", somSelf->GetID(ev));
- SOM_ENDTRY
- }
-
- /*
- * SOM_Scope void SOMLINK AppleTest_ContainerExternalizeKinds(AppleTest_Container *somSelf, Environment *ev,
- * ODTypeSet* kindset)
- */
-
- /*
- * The prototype for AppleTest_ContainerExternalizeKinds was replaced by the following prototype:
- */
- SOM_Scope void SOMLINK AppleTest_ContainerExternalizeKinds(AppleTest_Container *somSelf, Environment *ev,
- ODTypeList* kindset)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ExternalizeKinds");
-
- SOM_TRY
-
- ODUnused(kindset);
- somSelf->Externalize(ev);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerExternalize(AppleTest_Container *somSelf, Environment *ev)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","Externalize");
-
- SOM_TRY
-
- parent_Externalize(somSelf,ev);
- // UpdateModificationInfo(ev, somSelf->GetStorageUnit(ev));
-
- // SimplePart::Externalize();
- // since SimplePart has no Externalize method, I assume this just calls
- // the same code as AppleTest_Container_parent_ODPart_Externalize. So ignore.
-
- ODStorageUnit* su = _fTestDrawSU;
- ODStorageUnitRef aSURef;
- ODULong offset;
- ODFrame* frame;
- Proxy* proxy;
- OrderedCollectionIterator aIter(_fDisplayFrames);
- // OrderedCollectionIterator bIter(_fEmbeddedFrames);
- OrderedCollectionIterator cIter(_fContents);
- Point xform;
-
- ODSetBooleanProp(ev, su, kPropScriptingOn,kODBoolean, _fScriptingOn);
-
- ODSURemoveProperty(ev, su, kODPropDisplayFrames);
- ODSUAddPropValue(ev, su, kODPropDisplayFrames, kODWeakStorageUnitRef);
-
- offset = 0;
- for (frame = (ODFrame*)aIter.First(); aIter.IsNotComplete();
- frame = (ODFrame*)aIter.Next(), offset+=sizeof(ODStorageUnitRef))
- {
- frame->Externalize(ev);
- su->GetWeakStorageUnitRef(ev, frame->GetStorageUnit(ev)->GetID(ev), aSURef);
- su->SetOffset(ev, offset);
- StorageUnitSetValue(su, ev, sizeof(ODStorageUnitRef), aSURef);
- }
-
- ODSetULongProp(ev, su, kODPropFrameGroup, kODULong, _fFrameGroupIDCounter);
-
- ODSURemoveProperty(ev, su, kODPropEmbeddedFrames);
- ODSUAddPropValue(ev, su, kODPropEmbeddedFrames, kODStrongStorageUnitRef);
- // $$$$$ should be something DrawPart specific, not kODStrongStorageUnitRef
- // since it is storing StorageUnitRefs and xforms in the same stream.
-
- offset = 0;
- for (proxy = (Proxy*)cIter.First();
- cIter.IsNotComplete();
- proxy = (Proxy*)cIter.Next())
- {
- proxy->frame->Externalize(ev);
- su->GetStrongStorageUnitRef(ev, proxy->frame->GetStorageUnit(ev)->GetID(ev), aSURef);
- su->SetOffset(ev, offset);
- StorageUnitSetValue(su, ev, sizeof(ODStorageUnitRef), aSURef);
- offset += sizeof(ODStorageUnitRef);
-
- xform = proxy->transform->GetQDOffset(ev);
- su->SetOffset(ev, offset);
- StorageUnitSetValue(su, ev, sizeof(ODPlatformTransform), (ODValue)&xform);
- offset += sizeof(Point);
- }
-
- su = somSelf->GetStorageUnit(ev);
- ODSetStrongSURefProp(ev, su, kODPropContents,kKindTestDraw, _fTestDrawSU->GetID(ev));
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerChangeKind(AppleTest_Container *somSelf, Environment *ev,
- ODType kind)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ChangeKind");
-
- SOM_TRY
-
- ODUnused(kind);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerHandleEvent(AppleTest_Container *somSelf, Environment *ev,
- ODEventData* event,
- ODFrame* frame,
- ODFacet* facet,
- ODEventInfo* eventInfo)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HandleEvent");
-
- SOM_TRY
-
- Point windowPoint;
- GrafPtr curPort;
- ODBoolean handled = kODFalse;
-
- #if ODDebug
- // somPrintf("Draw %d::HandleEvent in frame %d, facet %x\n", somSelf->GetID(ev),
- // (frame ? frame->GetID(ev) : 0), facet);
- #endif
-
- switch (event->what)
- {
- case nullEvent:
- break;
-
- case mouseDown:
- case kODEvtBGMouseDown:
- if (_fDrawingLines)
- {
- somSelf->StopDrawingLines(ev, frame);
- WindowPtr platformWindow = kODNULL;
- short partCode;
- partCode = FindWindow ( event->where, &platformWindow );
- if (partCode == inMenuBar)
- _fSession->GetDispatcher(ev)->Dispatch(ev, event);
- }
-
- {
- windowPoint = event->where;
- GetPort(&curPort);
- SetPort(facet->GetWindow(ev)->GetPlatformWindow(ev));
- SetOrigin(0,0);
- GlobalToLocal(&windowPoint);
- ODPoint windowODPoint(windowPoint);
-
- if( event->what==mouseDown )
- handled = somSelf->HandleMouseDown(ev, facet, &windowODPoint, event);
- else
- handled = somSelf->HandleBGMouseDown(ev, facet, &windowODPoint, event);
-
- SetPort(curPort);
- }
- break;
-
- case kODEvtWindow:
- {
- if (_fDrawingLines)
- somSelf->StopDrawingLines(ev, frame);
- switch (event->message)
- {
- case inGoAway:
- ODWindow* window = facet->GetWindow(ev);
- if (window == _fPalette) {
- somSelf->HidePalette(ev);
- _fPaletteUp = kODFalse;
- }
- break;
- case inZoomIn:
- case inZoomOut:
- SysBeep(2);
- handled = kODTrue;
- break;
- default:
- break;
- }
- }
- break;
-
- case mouseUp:
- #if defined(ODDebug) && ODDebugActivates
- somPrintf("Draw %d::Mouse Up: Calling IsActive\n", somSelf->GetID(ev));
- #endif
- if (!facet->GetWindow(ev)->IsActive(ev))
- {
- #if defined(ODDebug) && ODDebugActivates
- somPrintf("Draw %d::Mouse Up: Calling Select\n", somSelf->GetID(ev));
- #endif
- facet->GetWindow(ev)->Select(ev);
- }
- else
- somSelf->ActivateFrame(ev, facet->GetFrame(ev));
- handled = kODTrue;
- break;
-
- case keyDown:
- case autoKey:
- handled = somSelf->HandleKeyDown(ev, frame, event);
- break;
-
- case activateEvt:
- if (_fDrawingLines)
- somSelf->StopDrawingLines(ev, frame);
- handled = true; // actually ignored by dispatcher
- if ((event->modifiers & activeFlag) != 0)
- somSelf->ActivatingWindow(ev, frame);
- else
- somSelf->DeActivatingWindow(ev, frame);
- break;
-
- case keyUp:
- break;
-
- case osEvt:
- {
- unsigned char typeOSEvent;
-
- // • Is it a multifinder event?
- typeOSEvent = (unsigned char) (event->message >> 24) & 0x00FF;
-
- // • Switch on the type of OSEvent that occurred, high byte of message is event type
- switch (typeOSEvent)
- {
- case kMouseMovedMessage:
- break;
-
- case kSuspendResumeMessage:
- {
- if (_fDrawingLines)
- somSelf->StopDrawingLines(ev, frame);
- const short kResumeMask = 0x01; // High byte suspend/resume event
- ODBoolean goingToBackground = (event->message & kResumeMask) == 0;
- ODWindow* window = facet->GetWindow(ev);
- if (window && window != _fPalette)
- {
- if (goingToBackground)
- {
- #if ODDebug
- // somPrintf("DrawPart Suspend Event\n");
- #endif
- if (_fPalette && _fPalette->IsShown(ev))
- {
- _fPaletteWasShown = kODTrue;
- somSelf->HidePalette(ev);
- _fPaletteUp = kODFalse;
- }
- else
- _fPaletteWasShown = kODFalse;
- }
- else
- {
- #if ODDebug
- // somPrintf("DrawPart Resume Event\n");
- #endif
- if (_fPaletteWasShown)
- {
- _fPaletteUp = kODTrue;
- somSelf->ShowPalette(ev);
- }
- }
- }
-
- }
- break;
- }
- }
-
- break;
-
- case kHighLevelEvent:
- break;
-
- case kODEvtMenu:
- if (_fDrawingLines)
- somSelf->StopDrawingLines(ev, frame);
- else
- handled = somSelf->HandleMenuEvent(ev, frame, event);
- break;
-
- case kODEvtMouseDownEmbedded:
- case kODEvtBGMouseDownEmbedded:
- {
- //#if ODDebug
- // somPrintf("Draw %d::MouseDownInEmbedded in frame %d, facet %x, embedded frame %d, embedded facet %x\n", somSelf->GetID(ev),
- // (frame ? frame->GetID(ev) : 0), facet, (eventInfo->embeddedFrame ? eventInfo->embeddedFrame->GetID(ev) : 0), eventInfo->embeddedFacet);
- //#endif
-
- // $$$$$ Note: Could use eventInfo->where, which is in frame coordinates
- windowPoint = event->where;
- GetPort(&curPort);
- SetPort(facet->GetWindow(ev)->GetPlatformWindow(ev));
- SetOrigin(0,0);
- GlobalToLocal(&windowPoint);
- ODPoint ODWindowPoint (windowPoint);
- handled = somSelf->HandleMouseDownInEmbeddedFrame(ev, facet,
- eventInfo->embeddedFacet,
- &ODWindowPoint, event);
- SetPort(curPort);
- }
- break;
-
- case kODEvtMouseDownBorder:
- {
- if (!facet->GetWindow(ev)->IsActive(ev))
- facet->GetWindow(ev)->Select(ev);
- else
- somSelf->ActivateFrame(ev, facet->GetFrame(ev));
-
- ODSLong savedRefNum;
- BeginUsingLibraryResources(savedRefNum);
- SetCursor(*GetCursor(284)); // Closed Hand Cursor
- EndUsingLibraryResources(savedRefNum);
-
- windowPoint = event->where;
- GetPort(&curPort);
- SetPort(facet->GetWindow(ev)->GetPlatformWindow(ev));
- SetOrigin(0,0);
- GlobalToLocal(&windowPoint);
- ODPoint ODWindowPoint (windowPoint);
- handled = somSelf->HandleMouseDownInEmbeddedFrame(ev, facet,
- eventInfo->embeddedFacet,
- &ODWindowPoint, event);
- SetPort(curPort);
- }
- break;
-
- case kODEvtMouseUpEmbedded:
- //facet->GetFrame(ev)->SetDragging(ev, kODFalse);
- #if defined(ODDebug) && ODDebugActivates
- somPrintf("Draw %d::Mouse Down: Calling IsActive\n", somSelf->GetID(ev));
- #endif
- if (!facet->GetWindow(ev)->IsActive(ev))
- {
- #if defined(ODDebug) && ODDebugActivates
- somPrintf("Draw %d::Mouse Down: Calling Select\n", somSelf->GetID(ev));
- #endif
- facet->GetWindow(ev)->Select(ev);
- }
- else
- somSelf->ActivateFrame(ev, facet->GetFrame(ev));
- handled = kODTrue;
- break;
-
- case kODEvtMouseEnter:
- #if defined(ODDebug) && ODDebugCursor
- somPrintf("MouseEnter %d %d\n",eventInfo->where.IntX(),eventInfo->where.IntY());
- #endif
- case kODEvtMouseWithin:
- #if defined(ODDebug) && ODDebugCursor
- somPrintf("MouseWithin %d %d\n",eventInfo->where.IntX(),eventInfo->where.IntY());
- #endif
- {
- // Note: ODFacet::ActiveBorderContainsPoint takes frame coordinates
- ODBoolean cursorInActiveBorder = kODFalse;
- ODArbitrator* fArbitrator = _fSession->GetArbitrator(ev);
- ODFrame* activeFrame = fArbitrator->AcquireFocusOwner(ev, _fSelectionFocus);
- WASSERTM(activeFrame != kODNULL, "Noone owns the selection focus, i.e. No active frame.");
- if (activeFrame)
- {
- ODFrameFacetIterator* iter = activeFrame->CreateFacetIterator(ev);
- ODReleaseObject(ev, activeFrame);
-
- ODPoint windowMouse = eventInfo->where;
- { TempODTransform windowFrameXForm = facet->AcquireWindowFrameTransform(ev, kODNULL);
- windowFrameXForm->TransformPoint(ev, &windowMouse);
- }
-
- if (_fDrawingLines)
- {
- CFocus focus(ev, facet);
-
- PenNormal();
- MoveTo(gLastPoint.h, gLastPoint.v);
- Point qdPt = eventInfo->where.AsQDPoint(); // windowMouse.AsQDPoint();
- LineTo(qdPt.h, qdPt.v);
- handled = kODTrue;
- return handled;
- }
-
- for (ODFacet* facet = iter->First(ev); iter->IsNotComplete(ev);
- facet = iter->Next(ev))
- {
- ODPoint framePoint = windowMouse;
- { TempODTransform xForm = facet->AcquireWindowFrameTransform(ev, kODNULL);
- xForm->InvertPoint(ev, &framePoint);
- }
-
- if (facet->ActiveBorderContainsPoint(ev,&framePoint,kODNULL))
- {
- cursorInActiveBorder = kODTrue;
- break;
- }
- }
- ODDeleteObject(iter);
- }
- if (cursorInActiveBorder)
- {
- ODSLong savedRefNum;
- BeginUsingLibraryResources(savedRefNum);
- SetCursor(*GetCursor(283)); // Hand Cursor
- EndUsingLibraryResources(savedRefNum);
- }
- else
- SetCursor(*GetCursor(crossCursor)); // For now.
-
- }
- handled = kODTrue;
- break;
- case kODEvtMouseLeave:
- #if defined(ODDebug) && ODDebugCursor
- somPrintf("MouseLeave\n");
- #endif
- SetCursor(&ODQDGlobals.arrow);
- handled = kODTrue;
- break;
-
-
- default:
- return kODFalse;
- }
- return handled;
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
-
-
- SOM_Scope void SOMLINK AppleTest_ContainerAdjustMenus(AppleTest_Container *somSelf, Environment *ev,
- ODFrame* frame)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","AdjustMenus");
-
- SOM_TRY
-
- PartInfoRec* pInfo = (PartInfoRec*) frame->GetPartInfo(ev);
- ODIText* menuItem = kODNULL;
-
- // if this frame is the root frame, enable printing.
-
- TempODFrame tempFrame = frame->AcquireContainingFrame(ev);
- if (tempFrame == kODNULL)
- {
- _fMenuBar->EnableCommand(ev, kODCommandPageSetup, kODTrue);
- _fMenuBar->EnableCommand(ev, kODCommandPrint, kODTrue);
- }
- else
- {
- //_fMenuBar->EnableCommand(ev, kODCommandPageSetup, kODFalse);
- //_fMenuBar->EnableCommand(ev, kODCommandPrint, kODFalse);
- }
-
- // $$$$$ The rest of these should only be done if we have the menu focus
- // This test could be avoided by looking at partInfo->fIsActive
- ODFrame* menuFocus = _fSession->GetArbitrator(ev)->AcquireFocusOwner(ev, _fMenuFocus);
- if (!frame->IsEqualTo(ev, menuFocus))
- {
- ODReleaseObject(ev, menuFocus);
- return;
- }
- else
- ODReleaseObject(ev, menuFocus);
- _fMenuBar->EnableCommand(ev, kODCommandViewAsWin, kODFalse); // !frame->IsRoot(ev));
-
- // parts bin code stolen from clock.cpp
- if ( _fPartsBinWin != 0)
- {
- ODWindow* window = _fSession->GetWindowState(ev)->AcquireWindow(ev, _fPartsBinWin);
- if (window)
- {
- _fPartsBinOpen = window->IsActive(ev);
- ODReleaseObject(ev, window);
- }
- else
- _fPartsBinOpen = kODFalse; // $$$$$ SHOULD NEVER HAPPEN - BAD!!!!
- }
-
- #ifndef NUKE_PARTSBIN_FOR_DR
- if (_fPartsBinOpen)
- {
- // INTL BUG: FOR LOCALISABILITY, READ THE TEXT OUT OF A RESOURCE AND
- // USE THE CURRENT SYSTEM SCRIPT AND CURRENT SYSTEM LANGUAGE.
- menuItem = CreateIText(smRoman, langEnglish, "Hide Parts Bin");
- }
- else
- {
- // INTL BUG: FOR LOCALISABILITY, READ THE TEXT OUT OF A RESOURCE AND
- // USE THE CURRENT SYSTEM SCRIPT AND CURRENT SYSTEM LANGUAGE.
- menuItem = CreateIText(smRoman, langEnglish, "Show Parts Bin");
- }
- _fMenuBar->SetItemString(ev, kODCommandShowPartsBin, menuItem);
- DisposeIText(menuItem);
-
- _fMenuBar->EnableCommand(ev, kODCommandShowPartsBin, kODTrue);
- #endif
-
- // PREFERENCES
- _fMenuBar->EnableCommand(ev, kODCommandPreferences, kODTrue ) ;
- // INTL BUG: FOR LOCALISABILITY, READ THE TEXT OUT OF A RESOURCE AND
- // USE THE CURRENT SYSTEM SCRIPT AND CURRENT SYSTEM LANGUAGE.
- menuItem = CreateIText(smRoman, langEnglish, "DrawPart Preferences…");
- _fMenuBar->SetItemString(ev, kODCommandPreferences, menuItem);
- DisposeIText(menuItem);
-
- // ABOUT
- _fMenuBar->EnableCommand(ev, kODCommandAbout, kODTrue ) ;
- // INTL BUG: FOR LOCALISABILITY, READ THE TEXT OUT OF A RESOURCE AND
- // USE THE CURRENT SYSTEM SCRIPT AND CURRENT SYSTEM LANGUAGE.
- menuItem = CreateIText(smRoman, langEnglish, "About Test Container…");
- _fMenuBar->SetItemString(ev, kODCommandAbout, menuItem);
- DisposeIText(menuItem);
-
- _fMenuBar->EnableAndCheckCommand(ev, cGray, kODTrue, RGBEqual(pInfo->bgColor,rgbGray));
- _fMenuBar->EnableAndCheckCommand(ev, cRed, kODTrue, RGBEqual(pInfo->bgColor,rgbRed));
- _fMenuBar->EnableAndCheckCommand(ev, cGreen, kODTrue, RGBEqual(pInfo->bgColor,rgbGreen));
- _fMenuBar->EnableAndCheckCommand(ev, cYellow, kODTrue, RGBEqual(pInfo->bgColor,rgbYellow));
- _fMenuBar->EnableAndCheckCommand(ev, cBlue, kODTrue, RGBEqual(pInfo->bgColor,rgbBlue));
- _fMenuBar->EnableAndCheckCommand(ev, cMagenta, kODTrue, RGBEqual(pInfo->bgColor,rgbMagenta));
- _fMenuBar->EnableAndCheckCommand(ev, cCyan, kODTrue, RGBEqual(pInfo->bgColor,rgbCyan));
- _fMenuBar->EnableAndCheckCommand(ev, cWhite, kODTrue, RGBEqual(pInfo->bgColor,rgbWhite));
- _fMenuBar->EnableCommand(ev, cOtherColor, kODTrue);
-
- // if a part is selected
- ODBoolean hasSelection = _fSelection->Count()>0;
-
- _fMenuBar->EnableCommand(ev, kODCommandClear, hasSelection); // kODFalse);
- _fMenuBar->EnableCommand(ev, kODCommandSelectAll, kODFalse); // _fEmbeddedFrames->Count()>0);
-
- _fMenuBar->EnableCommand(ev, kODCommandOpen, hasSelection);
-
- ODIText* partInfoText;
- // INTL BUG: FOR LOCALISABILITY, READ THE TEXT OUT OF A RESOURCE AND
- // USE THE CURRENT SYSTEM SCRIPT AND CURRENT SYSTEM LANGUAGE.
- partInfoText = CreateIText(smRoman, langEnglish, "Part Info");
- _fMenuBar->SetItemString(ev, kODCommandGetPartInfo, partInfoText);
- DisposeIText(partInfoText);
- _fMenuBar->EnableCommand(ev, kODCommandGetPartInfo, (!frame->IsRoot(ev) || hasSelection));
-
- ODArbitrator* arbitrator = _fSession->GetArbitrator(ev);
-
- ODFrame* clipboardFocus = arbitrator->AcquireFocusOwner(ev, _fClipboardFocus);
- if ( (frame == clipboardFocus) ||
- (arbitrator->RequestFocus(ev, _fClipboardFocus, frame)) )
- {
- _fMenuBar->EnableCommand(ev, kODCommandCut, kODFalse); // hasSelection);
- _fMenuBar->EnableCommand(ev, kODCommandCopy, kODFalse); // hasSelection);
- _fMenuBar->EnableCommand(ev, kODCommandPaste, kODFalse); // ValueOnClipboard(ev, _fSession));
- _fMenuBar->EnableCommand(ev, kODCommandPasteAs, kODFalse);
- }
- ODReleaseObject(ev, clipboardFocus);
-
- #ifdef SCRIPTDEBUG
- ODIText* scriptMenuText;
- if (_fScriptingOn) scriptMenuText = CreateIText(smRoman, langEnglish, "Turn Scripting Off");
- else scriptMenuText = CreateIText(smRoman, langEnglish, "Turn Scripting On");
- _fMenuBar->SetItemString(ev, cToggleScripting, scriptMenuText);
- DisposeIText(scriptMenuText);
- _fMenuBar->EnableCommand(ev, cToggleScripting, kODTrue);
- #endif
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerUndoAction(AppleTest_Container *somSelf, Environment *ev,
- ODActionData* actionState)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","UndoAction");
-
- SOM_TRY
-
- // FOR NOW, WE JUST HAVE ONE ACTION THAT CAN BE UNDONE OR REDONE.
- SetBGColorRec* undoRec = *((SetBGColorRec**)actionState->_buffer);
-
- somSelf->SetBGColor2(ev, undoRec->_fFrame, &undoRec->_fOldColor);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerRedoAction(AppleTest_Container *somSelf, Environment *ev,
- ODActionData* actionState)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","RedoAction");
-
- SOM_TRY
-
- // FOR NOW, WE JUST HAVE ONE ACTION THAT CAN BE UNDONE OR REDONE.
- SetBGColorRec* undoRec = *((SetBGColorRec**)actionState->_buffer);
-
- somSelf->SetBGColor2(ev, undoRec->_fFrame, &undoRec->_fNewColor);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerDisposeActionState(AppleTest_Container *somSelf, Environment *ev,
- ODActionData* actionState,
- ODDoneState doneState)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","DisposeActionState");
-
- SOM_TRY
-
- ODUnused(doneState);
- // FOR NOW, WE JUST HAVE ONE ACTION THAT CAN BE UNDONE OR REDONE.
- delete *((SetBGColorRec**)actionState->_buffer);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerWriteActionState(AppleTest_Container *somSelf, Environment *ev,
- ODActionData* actionState,
- ODStorageUnitView* storageUnitView)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","WriteActionState");
-
- SOM_TRY
-
- ODUnused(actionState);
- ODUnused(storageUnitView);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope ODActionData SOMLINK AppleTest_ContainerReadActionState(AppleTest_Container *somSelf, Environment *ev,
- ODStorageUnitView* storageUnitView)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ReadActionState");
-
- ODActionData data;
- ODUnused(storageUnitView);
- data._maximum = 0;
- data._length = 0;
- data._buffer = kODNULL;
- return data;
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerInitPart(AppleTest_Container *somSelf, Environment *ev,
- ODStorageUnit* storageUnit, ODPart* partWrapper)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","InitPart");
-
- SOM_TRY
-
- parent_InitPart(somSelf, ev, storageUnit, partWrapper);
-
- _fPartWrapper = partWrapper;
-
- somSelf->CommonInitContainerPart(ev);
-
- ODStorageUnit* msu = somSelf->GetStorageUnit(ev);
- ODSUAddPropValue(ev, msu, kODPropContents, kKindTestDraw);
- _fTestDrawSU = msu->GetDraft(ev)->CreateStorageUnit(ev);
-
- ODSUAddPropValue(ev, _fTestDrawSU, kPropScriptingOn, kODBoolean);
- ODSUAddPropValue(ev, _fTestDrawSU, kODPropDisplayFrames, kODWeakStorageUnitRefs);
- ODSUAddPropValue(ev, _fTestDrawSU, kODPropFrameGroup, kODULong);
- ODSUAddPropValue(ev, _fTestDrawSU, kODPropEmbeddedFrames, kODStrongStorageUnitRef);
- // $$$$$ The type should be something DrawPart specific, not kODStrongStorageUnitRef
- // since it is storing StorageUnitRefs and xforms in the same stream.
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- SOM_Scope void SOMLINK AppleTest_ContainerInitPartFromStorage(AppleTest_Container *somSelf, Environment *ev,
- ODStorageUnit* storageUnit, ODPart* partWrapper)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","InitPartFromStorage");
-
- SOM_TRY
-
- parent_InitPartFromStorage(somSelf, ev, storageUnit, partWrapper);
-
- _fPartWrapper = partWrapper;
-
- somSelf->CommonInitContainerPart(ev);
-
- ODStorageUnit* su;
- ODStorageUnitRef aSURef;
- ODShape* newShape;
- ODULong offset, offsetLimit;
- ODRgnHandle newRegion;
- Point xform;
-
- ODUnused(newRegion);
-
- su = somSelf->GetStorageUnit(ev);
-
- _fTestDrawSU = su->GetDraft(ev)->AcquireStorageUnit(ev,
- ODGetStrongSURefProp(ev, su, kODPropContents, kKindTestDraw));
-
- su = _fTestDrawSU;
-
- _fScriptingOn = ODGetBooleanProp(ev, su, kPropScriptingOn, kODBoolean);
-
- su->Focus(ev, kODPropDisplayFrames, kODPosSame, 0, 1, kODPosFirstSib);
- offsetLimit = su->GetSize(ev);
- for (offset = 0; offset < offsetLimit; offset += sizeof(ODStorageUnitRef))
- {
- su->SetOffset(ev, offset);
- StorageUnitGetValue(su, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
-
- if (su->IsValidStorageUnitRef(ev, aSURef)) {
- ODFrame* frame =
- su->GetDraft(ev)->AcquireFrame(ev, su->GetIDFromStorageUnitRef(ev, aSURef));
- _fDisplayFrames->AddLast((ElementType)frame);
- frame->SetDroppable(ev, kODTrue);
- }
- }
-
- _fFrameGroupIDCounter = ODGetULongProp(ev, su, kODPropFrameGroup, kODULong);
-
- su->Focus(ev, kODPropEmbeddedFrames,kODPosSame,0,1,kODPosFirstSib);
- offsetLimit = su->GetSize(ev);
- newShape = kODNULL;
- for (offset = 0; offset < offsetLimit;)
- {
- su->SetOffset(ev, offset);
- StorageUnitGetValue(su, ev, sizeof(ODStorageUnitRef), (ODValue)&aSURef);
- offset += sizeof(ODStorageUnitRef);
- ODFrame* frame =
- su->GetDraft(ev)->AcquireFrame(ev, su->GetIDFromStorageUnitRef(ev, aSURef)); // TÇ: frame is consumed below.
- _fEmbeddedFrames->AddLast((ElementType)(ODFrame*)frame);
-
- su->SetOffset(ev, offset);
- StorageUnitGetValue(su, ev, sizeof(ODPlatformTransform), (ODValue)&xform);
- offset += sizeof(Point);
-
- ODTransform* transform =
- frame->CreateTransform(ev)->SetQDOffset(ev, &xform); // DMc SetQDOffset() returns this. TÇ: transform is consumed below.
-
- ODShape* frameShape = frame->AcquireFrameShape(ev, kODNULL);
- if( newShape )
- newShape->CopyFrom(ev, frameShape);
- else
- newShape = frameShape->Copy(ev);
-
- // TÇ: $$$$$ Should really be using CreateFrameProxy.
- frameShape->Release(ev); frameShape = kODNULL;
- newShape->Transform(ev, transform);
- RgnHandle newRegion = newShape->CopyQDRegion(ev);
- _fContents->AddLast((ElementType)(new Proxy(newRegion, (ODFrame*)frame, transform))); // TÇ: transform is consumed here.
- }
- if (newShape) newShape->Release(ev); newShape = kODNULL;
-
- // Remove any temporary properties that may have been cloned in during data interchange
- ODSURemoveProperty(ev, su, kODPropContentFrame);
- ODSURemoveProperty(ev, su, kODPropExternalTransform);
- ODSURemoveProperty(ev, su, kODPropSuggestedFrameShape);
- ODSURemoveProperty(ev, su, kODPropMouseDownOffset);
- ODSURemoveProperty(ev, su, kPropFrameInfo);
-
- SOM_CATCH_ALL_ENDTRY
- }
-
- // ••• ValueOnClipboard •••
-
- ODBoolean ValueOnClipboard(Environment* ev, ODSession* session)
- {
- ODBoolean result = kODFalse;
- ODClipboard* clipboard = session->GetClipboard(ev);
-
- TRY
- ODStorageUnit* su = clipboard->GetContentStorageUnit(ev);
- result = su->Exists(ev, kODPropContents, kODNULL, 0);
- CATCH_ALL
- ENDTRY
-
- return result;
- }
-
- //------------------------------------------------------------------------------
- // DrawPart::HasExtension
- //------------------------------------------------------------------------------
-
- SOM_Scope ODBoolean SOMLINK AppleTest_ContainerHasExtension(AppleTest_Container *somSelf, Environment *ev,
- ODType extensionName)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","HasExtension");
-
- SOM_TRY
-
- #ifdef SCRIPTDEBUG
- if (!_fScriptingOn) return kODFalse;
- #endif
-
- #ifndef SCRIPTING_OFF
- if (!ODISOStrCompare((ODISOStr)extensionName, kODExtSemanticInterface))
- return kODTrue;
- else
- #endif
- return kODFalse;
-
- SOM_CATCH_ALL_ENDTRY
- return kODFalse;
- }
-
-
- //------------------------------------------------------------------------------
- // DrawPart::AcquireExtension
- //------------------------------------------------------------------------------
-
- SOM_Scope ODExtension* SOMLINK AppleTest_ContainerAcquireExtension(AppleTest_Container *somSelf, Environment *ev,
- ODType extensionName)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","AcquireExtension");
-
- SOM_TRY
-
- #ifndef SCRIPTING_OFF
- if (!ODISOStrCompare((ODISOStr)extensionName, kODExtSemanticInterface))
- {
- _fSemtIntf->Acquire(ev);
- return _fSemtIntf;
- }
- else
- #endif
- return kODNULL;
-
- SOM_CATCH_ALL_ENDTRY
- return kODNULL;
- }
-
- //------------------------------------------------------------------------------
- // DrawPart::ReleaseExtension
- //------------------------------------------------------------------------------
-
- SOM_Scope void SOMLINK AppleTest_ContainerReleaseExtension(AppleTest_Container *somSelf, Environment *ev,
- ODExtension* extension)
- {
- AppleTest_ContainerData *somThis = AppleTest_ContainerGetData(somSelf);
- AppleTest_ContainerMethodDebug("AppleTest_Container","ReleaseExtension");
-
- SOM_TRY
-
- #ifndef SCRIPTING_OFF
- if( extension == _fSemtIntf )
- _fSemtIntf = kODNULL;
- delete extension;
- #endif
-
- SOM_CATCH_ALL_ENDTRY
- }
-
-
- //------------------------------------------------------------------------------
- // AboutDialogFilter
- //------------------------------------------------------------------------------
-
- pascal Boolean AboutDialogFilter(DialogPtr dialog,
- EventRecord* event,
- short* itemHit)
- {
- ODBoolean handled = kODFalse;
-
- Environment* ev = somGetGlobalEnvironment();
-
- if (event->what == nullEvent)
- {
- gSession->GetDispatcher(ev)->Dispatch(ev, (ODEventData*)event);
- }
- else if (event->what == updateEvt &&
- (WindowPtr) event->message != dialog)
- {
- gSession->GetDispatcher(ev)->Dispatch(ev, (ODEventData*)event);
- }
- else if (event->what == activateEvt &&
- (WindowPtr) event->message != dialog)
- {
- gSession->GetDispatcher(ev)->Dispatch(ev, (ODEventData*)event);
- }
- else if (event->what == mouseDown)
- {
- handled = kODFalse;
- }
- else if (event->what == mouseUp)
- {
- handled = kODTrue;
- *itemHit = 1;
- }
- else if ((event->what == keyDown) || (event->what == autoKey))
- {
- handled = kODTrue;
- }
-
- return handled;
- }
-
- void ShowMyDragHilite(Environment* ev, ODDragAndDrop* dad, ODFacet* facet)
- {
- if (facet != kODNULL) {
- ODULong attributes = dad->GetDragAttributes(ev);
- if ((!(attributes & kODDragIsInSourceFrame)) && (gDragHilitedFacet != facet)) {
-
- CommonInvertFacet(ev, dad, facet, true);
- gDragHilitedFacet = facet;
- }
- }
- }
-
- void HideMyDragHilite(Environment* ev, ODDragAndDrop* dad, ODFacet* facet)
- {
- if (gDragHilitedFacet == facet) {
- CommonInvertFacet(ev, dad, facet, false);
- gDragHilitedFacet = kODNULL;
- }
- }
-
- void CommonInvertFacet(Environment* ev, ODDragAndDrop* dad, ODFacet* facet, ODBoolean show)
- {
- CFocus prepareForRendering(ev, facet);
- ODFrame* displayFrame = facet->GetFrame(ev);
- TempODShape frameShape = displayFrame->AcquireFrameShape(ev, kODNULL); // DMc refcount - make temp
- RgnHandle bRgn = frameShape->GetQDRegion(ev);
-
- #ifndef UseMyDragHilite
- RgnHandle destRgn = NewRgn();
- CopyRgn(bRgn, destRgn);
- InsetRgn(destRgn, 3, 3);
- XorRgn(bRgn, destRgn, destRgn);
- InvertRgn(destRgn);
- ODDisposeHandle((Handle)destRgn);
-
- #else
-
- if (show)
- ShowDragHilite(dad->GetDragReference(ev), bRgn, true);
- else
- HideDragHilite(dad->GetDragReference(ev));
-
- #endif
- }
-
- #undef VARIABLE_MACROS
-